NestJS
NestJS 中间件与请求生命周期:函数中间件与全局注册机制
Waitwalker2026-08-2212 min
## 1. 请求处理流水线黄金时序
```
Incoming Request
↓
1. Global & Route Middleware (中间件)
↓
2. Global, Controller & Route Guards (守卫)
↓
3. Global, Controller & Route Interceptors (拦截器 - 前置)
↓
4. Global, Controller & Route Pipes (管道校验)
↓
5. Controller Route Handler (业务方法执行)
↓
6. Service & Data Layer (业务逻辑与数据库)
↓
7. Route, Controller & Global Interceptors (拦截器 - 后置/响应转换)
↓
8. Exception Filters (异常捕获 - 若有错误)
↓
Outgoing Response
```
#NestJS#Middleware#请求生命周期#AOP
回到文章列表 →