perf(proxy): reduce nest rewrite allocations

- Dispatch shell link rewriting between streaming and buffered paths based on response size

- Reuse buffers and reduce URL construction allocations in proxy handlers

- Add nest benchmarks and align extractParts compatibility expectations with the current contract
This commit is contained in:
wjqserver 2026-04-12 00:02:54 +08:00
parent 4c555ed50c
commit e2719aa761
6 changed files with 248 additions and 88 deletions

View file

@ -44,17 +44,12 @@ func RoutingHandler(cfg *config.Config) touka.HandlerFunc {
return
}
// 处理blob/raw路径
rawPath = buildProxyPath(rawPath, matcher)
if matcher == "blob" {
rawPath = rawPath[10:]
rawPath = "raw.githubusercontent.com" + rawPath
rawPath = strings.Replace(rawPath, "/blob/", "/", 1)
matcher = "raw"
}
// 为rawpath加入https:// 头
rawPath = "https://" + rawPath
switch matcher {
case "releases", "blob", "raw", "gist", "api":
ChunkedProxyRequest(ctx, c, rawPath, cfg, matcher)