build: add api server health endpoint

This commit is contained in:
2026-04-21 01:36:04 +08:00
parent 6ada003c78
commit ec04790848
7 changed files with 145 additions and 6 deletions

View File

@@ -31,7 +31,7 @@
2. [x] 接入 `request_id`
3. [x] 接入统一错误处理中间件
4. [x] 接入 response envelope
5. [ ] 接入 `/healthz`
5. [x] 接入 `/healthz`
当前 tracing 约定:
@@ -64,6 +64,13 @@
3. 所有响应都会回写 `x-route-version`,当前阶段默认与 `x-api-version` 保持一致,后续再按路由粒度细分。
4. 所有响应都会回写 `x-response-time-ms`,值来源于 `RequestContext` 内记录的请求开始时间。
当前 `/healthz` 约定:
1. 路径固定为 `/healthz`
2. 裸响应继续返回 `{ ok: true, service: "genarrative-node-server" }`,保持与当前 Node 工程兼容。
3. 当请求携带 `x-genarrative-response-envelope` 时,`/healthz` 会返回标准 success envelope。
4. `x-request-id``x-api-version``x-route-version``x-response-time-ms` 会在 `/healthz` 响应中一并回写。
## 3. 边界约束
1. `api-server` 负责 HTTP、SSE、Cookie、Header、路由与协议装配。