mirror of https://github.com/tiangolo/fastapi.git
📝 Upate docs for advanced dependencies with `yield`, noting the changes in 0.121.0, adding `scope` (#14287)
This commit is contained in:
parent
4efae81a76
commit
289b4aa2fa
|
|
@ -70,12 +70,22 @@ If you understood all this, you already know how those utility tools for securit
|
||||||
|
|
||||||
You most probably don't need these technical details.
|
You most probably don't need these technical details.
|
||||||
|
|
||||||
These details are useful mainly if you had a FastAPI application older than 0.118.0 and you are facing issues with dependencies with `yield`.
|
These details are useful mainly if you had a FastAPI application older than 0.121.0 and you are facing issues with dependencies with `yield`.
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
Dependencies with `yield` have evolved over time to account for the different use cases and to fix some issues, here's a summary of what has changed.
|
Dependencies with `yield` have evolved over time to account for the different use cases and to fix some issues, here's a summary of what has changed.
|
||||||
|
|
||||||
|
### Dependencies with `yield` and `scope` { #dependencies-with-yield-and-scope }
|
||||||
|
|
||||||
|
In version 0.121.0, FastAPI added support for `Depends(scope="function")` for dependencies with `yield`.
|
||||||
|
|
||||||
|
Using `Depends(scope="function")`, the exit code after `yield` is executed right after the *path operation function* is finished, before the response is sent back to the client.
|
||||||
|
|
||||||
|
And when using `Depends(scope="request")` (the default), the exit code after `yield` is executed after the response is sent.
|
||||||
|
|
||||||
|
You can read more about it in the docs for [Dependencies with `yield` - Early exit and `scope`](../tutorial/dependencies/dependencies-with-yield.md#early-exit-and-scope).
|
||||||
|
|
||||||
### Dependencies with `yield` and `StreamingResponse`, Technical Details { #dependencies-with-yield-and-streamingresponse-technical-details }
|
### Dependencies with `yield` and `StreamingResponse`, Technical Details { #dependencies-with-yield-and-streamingresponse-technical-details }
|
||||||
|
|
||||||
Before FastAPI 0.118.0, if you used a dependency with `yield`, it would run the exit code after the *path operation function* returned but right before sending the response.
|
Before FastAPI 0.118.0, if you used a dependency with `yield`, it would run the exit code after the *path operation function* returned but right before sending the response.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue