mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-12 13:36:41 +00:00
📝 Improve naming of middleware in SQLAlchemy tutorial
This commit is contained in:
parent
22f4e18cdd
commit
9051ec3816
2 changed files with 3 additions and 1 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
## Next
|
## Next
|
||||||
|
|
||||||
|
* Improve middleware naming in tutorial for SQL with SQLAlchemy <a href="https://fastapi.tiangolo.com/tutorial/sql-databases/" target="_blank">https://fastapi.tiangolo.com/tutorial/sql-databases/</a>.
|
||||||
|
|
||||||
## 0.6.1
|
## 0.6.1
|
||||||
|
|
||||||
* Add docs for GraphQL: <a href="https://fastapi.tiangolo.com/tutorial/graphql/" target="_blank">https://fastapi.tiangolo.com/tutorial/graphql/</a>. PR <a href="https://github.com/tiangolo/fastapi/pull/48" target="_blank">#48</a>.
|
* Add docs for GraphQL: <a href="https://fastapi.tiangolo.com/tutorial/graphql/" target="_blank">https://fastapi.tiangolo.com/tutorial/graphql/</a>. PR <a href="https://github.com/tiangolo/fastapi/pull/48" target="_blank">#48</a>.
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ def read_user(request: Request, user_id: int):
|
||||||
|
|
||||||
|
|
||||||
@app.middleware("http")
|
@app.middleware("http")
|
||||||
async def close_db(request: Request, call_next):
|
async def db_session_middleware(request: Request, call_next):
|
||||||
request.state.db = Session()
|
request.state.db = Session()
|
||||||
response = await call_next(request)
|
response = await call_next(request)
|
||||||
request.state.db.close()
|
request.state.db.close()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue