refactor(proxy): streamline target URL selection logic by removing deprecated path handling

This commit is contained in:
wood chen 2025-01-12 18:24:19 +08:00
parent 8f27b8b70f
commit f76649d0e7

View File

@ -6,7 +6,6 @@ import (
"log"
"net/http"
"net/url"
"path"
"proxy-go/internal/config"
"proxy-go/internal/metrics"
"proxy-go/internal/utils"
@ -110,17 +109,8 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
// 确定标基础URL
targetBase := pathConfig.DefaultTarget
// 检查文件扩展名
if pathConfig.ExtensionMap != nil {
ext := strings.ToLower(path.Ext(decodedPath))
if ext != "" {
ext = ext[1:] // 移除开头的点
targetBase = pathConfig.GetTargetForExt(ext)
}
}
// 使用统一的路由选择逻辑
targetBase := utils.GetTargetURL(h.client, r, pathConfig, decodedPath)
// 重新编码路径,保留 '/'
parts := strings.Split(decodedPath, "/")