Aaron Timony
11 hours ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
14 additions and
3 deletions
-
docs/en/docs/tutorial/middleware.md
|
|
|
@ -82,9 +82,20 @@ app.add_middleware(MiddlewareB) |
|
|
|
|
|
|
|
This results in the following execution order: |
|
|
|
|
|
|
|
* **Request**: MiddlewareB → MiddlewareA → route |
|
|
|
|
|
|
|
* **Response**: route → MiddlewareA → MiddlewareB |
|
|
|
```mermaid |
|
|
|
sequenceDiagram |
|
|
|
participant Client |
|
|
|
participant B as Middleware B<br/>(added last · outermost) |
|
|
|
participant A as Middleware A<br/>(added first · innermost) |
|
|
|
participant App as FastAPI app |
|
|
|
|
|
|
|
Client ->> B: Request |
|
|
|
B ->> A: Request |
|
|
|
A ->> App: Request |
|
|
|
App -->> A: Response |
|
|
|
A -->> B: Response |
|
|
|
B -->> Client: Response |
|
|
|
``` |
|
|
|
|
|
|
|
This stacking behavior ensures that middlewares are executed in a predictable and controllable order. |
|
|
|
|
|
|
|
|