feat: httpc 集成改进,自动关联请求 Context

- 新增 contextHTTPClient 包装器,自动关联请求 Context
- 新增 Context.HTTPC() 方法返回 contextHTTPClient
- Client() 标记为 Deprecated
- 添加 GetHTTPC() go:fix inline 兼容函数

当请求被取消时,出站 HTTP 请求也会自动取消。
This commit is contained in:
wjqserver 2026-04-21 22:55:26 +08:00
parent 10033f4a17
commit f2295c3084
3 changed files with 86 additions and 7 deletions

View file

@ -4,7 +4,12 @@
// All rights reserved by WJQSERVER, related rights can be exercised by the infinite-iroha organization.
package touka
import "github.com/fenthope/reco"
import (
"github.com/WJQSERVER-STUDIO/httpc"
"github.com/fenthope/reco"
)
// --- reco 兼容函数 ---
// GetLogReco 返回底层的 reco.Logger 实例
// 用于需要访问 reco 特定功能的场景
@ -35,3 +40,13 @@ func (c *Context) GetLoggerReco() *reco.Logger {
}
return c.engine.LogReco
}
// --- httpc 兼容函数 ---
// GetHTTPC 返回底层的 httpc.Client 实例
// Deprecated: 使用 HTTPClient() 替代,新方法会自动关联请求 Context
//
//go:fix inline
func (c *Context) GetHTTPC() *httpc.Client {
return c.Client()
}