File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,18 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, Any]:
126126For a contextual session to work, a context needs to be set. This assumes some
127127kind of middleware.
128128
129+
130+ You can use ready-made FastAPI middleware:
131+ ``` python
132+ from fastapi import FastAPI
133+ from context_async_sqlalchemy import add_fastapi_db_session_middleware
134+
135+ app = FastAPI()
136+
137+ add_fastapi_db_session_middleware(app)
138+ ```
139+
140+
129141I'll use FastAPI middleware as an example:
130142``` python
131143from fastapi import Request
@@ -177,17 +189,6 @@ async def fastapi_db_session_middleware(
177189```
178190
179191
180- You can use ready-made FastAPI middleware:
181- ``` python
182- from fastapi import FastAPI
183- from context_async_sqlalchemy import add_fastapi_db_session_middleware
184-
185- app = FastAPI()
186-
187- add_fastapi_db_session_middleware(app)
188- ```
189-
190-
191192#### 4. Write a function that will work with the session
192193
193194``` python
You can’t perform that action at this time.
0 commit comments