build: add api server request context middleware
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
后续与本 package 直接相关的任务包括:
|
||||
|
||||
1. [x] 接入统一日志与 tracing
|
||||
2. [ ] 接入 `request_id`
|
||||
2. [x] 接入 `request_id`
|
||||
3. [ ] 接入统一错误处理中间件
|
||||
4. [ ] 接入 response envelope
|
||||
5. [ ] 接入 `/healthz`
|
||||
@@ -39,6 +39,12 @@
|
||||
2. 默认日志过滤器来自 `GENARRATIVE_API_LOG`,未提供时回落到 `info,tower_http=info`。
|
||||
3. HTTP 访问日志统一通过 Axum 路由层的 `TraceLayer` 输出,后续 `request_id`、响应头与错误中间件继续在同一层扩展。
|
||||
|
||||
当前 request context 约定:
|
||||
|
||||
1. 中间件优先读取来访 `x-request-id`,未提供时生成新的 UUID。
|
||||
2. `request_id` 会统一写入请求 `extensions` 与请求头,供 tracing、错误处理中间件和响应头层复用。
|
||||
3. 响应头回写 `x-request-id` 仍属于后续独立任务,本阶段只完成请求上下文准备。
|
||||
|
||||
## 3. 边界约束
|
||||
|
||||
1. `api-server` 负责 HTTP、SSE、Cookie、Header、路由与协议装配。
|
||||
|
||||
Reference in New Issue
Block a user