modify proxy handler

This commit is contained in:
2025-11-17 12:21:35 +08:00
parent 760e4a9b03
commit abfa51f12e
19 changed files with 755 additions and 52 deletions

View File

@@ -0,0 +1,31 @@
# Quickstart: Proxy Module Delegation
1) 检出分支
```bash
git checkout 005-proxy-module-delegation
```
2) 跑现有测试基线
```bash
go test ./...
```
3) 添加新模块示例(开发)
-`internal/hubmodule/<module>` 下实现元数据,并在 `init()` 中调用 `hubmodule.MustRegister`
- 为该模块实现专属 handler可基于 `internal/proxy/handler.go` 拓展),在启动时通过 `proxy.RegisterModule(proxy.ModuleRegistration{Key: "<module_key>", Handler: yourHandler})` 绑定。
-`config.toml` 中把目标 Hub 的 `Module` 字段设为这个 `module_key`
4) 启动代理验证
```bash
make run
# or
go run . --config ./config.toml
```
5) 验证缓存与日志
- 对同一路径请求两次,观察首次 cache_hit=false、二次 cache_hit=true日志包含 module_key/hub/domain/upstream_status。
- 验证缺失 handler 时返回 5xx 且日志含错误字段。
6) 更新文档与计划
- 填充 tasks 清单(/speckit.tasks
- 提交前复查 `specs/005-proxy-module-delegation` 下的设计/研究文件。