mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 16:41:54 +08:00
refactor(proxy): streamline target URL selection logic by removing deprecated path handling
This commit is contained in:
parent
8f27b8b70f
commit
f76649d0e7
@ -6,7 +6,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
|
||||||
"proxy-go/internal/config"
|
"proxy-go/internal/config"
|
||||||
"proxy-go/internal/metrics"
|
"proxy-go/internal/metrics"
|
||||||
"proxy-go/internal/utils"
|
"proxy-go/internal/utils"
|
||||||
@ -110,17 +109,8 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确定标基础URL
|
// 使用统一的路由选择逻辑
|
||||||
targetBase := pathConfig.DefaultTarget
|
targetBase := utils.GetTargetURL(h.client, r, pathConfig, decodedPath)
|
||||||
|
|
||||||
// 检查文件扩展名
|
|
||||||
if pathConfig.ExtensionMap != nil {
|
|
||||||
ext := strings.ToLower(path.Ext(decodedPath))
|
|
||||||
if ext != "" {
|
|
||||||
ext = ext[1:] // 移除开头的点
|
|
||||||
targetBase = pathConfig.GetTargetForExt(ext)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重新编码路径,保留 '/'
|
// 重新编码路径,保留 '/'
|
||||||
parts := strings.Split(decodedPath, "/")
|
parts := strings.Split(decodedPath, "/")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user