FastAPI 运行在 ASGI 之上,因此一个请求会经过一条异步 pipeline:ASGI server 接收它,middleware 包裹它,router 匹配 path,依赖被解析,你的 path operation 运行,返回值被 serialize 成响应。
各阶段
lua
uvicorn (ASGI server)
│ scope + receive/send
▼
ASGI / Starlette middleware ── (CORS, GZip, custom)
▼
Routing ── 匹配 method + → operation
▼
Dependencies (Depends) ── 解析 -deps、security、-setup
▼
Path operation 