Files
hose-use/src/http/README.http.md
T

17 lines
992 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# HTTP Daemon 说明
本目录是本地常驻 HTTP API 网关:暴露 CLI 能力的 HTTP 端点与交互式 OpenAPI 文档页。属入口层,业务调用一律经 `runCli` 委托 CLI 引擎,严禁直连 `domains/*/api.ts`。
## 文件职责
- `server.ts`:`startHttpServer` 启动常驻服务(默认 `127.0.0.1:8888`,可用 `HOST` / `PORT` 覆盖)。
- `routes.ts`:路由与安全——`isTrustedOrigin` 跨站来源校验、`checkHttpAuth` 访问令牌校验(`HOSE_HTTP_TOKEN` / `HOSE_HTTP_CORS_ORIGIN`)、`handleHttpRequest` 主分发。
- `docs.ts`:`renderDocsHtml` 渲染交互式 OpenAPI 文档页。
## 安全约束
- 默认仅绑定回环地址;跨站网页对 `/api/cli` 的调用被 `isTrustedOrigin` 阻断。
- 敏感字段输出经 `redactSensitiveText` 脱敏。
服务生命周期命令 `service start/stop/restart/run --dry-run` 只返回计划,不创建或终止进程、不改写 PID 和日志文件;状态与日志查询保留只读语义。