删除请求超时

This commit is contained in:
Sakurasan
2026-09-02 13:08:32 +08:00
parent 6d951a0d61
commit 923ac79039
5 changed files with 20 additions and 26 deletions
+6 -6
View File
@@ -109,7 +109,7 @@ func contains(list []string, s string) bool {
return false
}
func NewGateway(db *gorm.DB, enc *crypto.Encryptor, rec *usage.Recorder, lim *ratelimit.Limiter, userRPS int, logRaw bool) *Gateway {
func NewGateway(db *gorm.DB, enc *crypto.Encryptor, rec *usage.Recorder, lim *ratelimit.Limiter, userRPS int, logRaw bool, gw_timeout time.Duration) *Gateway {
return &Gateway{
db: db,
ch: channel.NewService(db, enc),
@@ -118,7 +118,7 @@ func NewGateway(db *gorm.DB, enc *crypto.Encryptor, rec *usage.Recorder, lim *ra
lim: lim,
userRPS: userRPS,
logRaw: logRaw,
hc: &http.Client{Timeout: 120 * time.Second},
hc: &http.Client{Timeout: gw_timeout * time.Second},
}
}
@@ -272,10 +272,10 @@ func upstreamPath(proto string) string {
// upstreamPlan 描述一次代理请求的上游访问方式。
type upstreamPlan struct {
proto string // 上游协议(用于分协议 base_url)
path string // 上游路径
body []byte // 已转换的请求体
lineConv func([]byte) []byte // 流式逐行转换(nil=直通)
proto string // 上游协议(用于分协议 base_url)
path string // 上游路径
body []byte // 已转换的请求体
lineConv func([]byte) []byte // 流式逐行转换(nil=直通)
bodyConv func([]byte) ([]byte, error) // 非流式响应体转换(nil=直通)
}