mirror of
https://github.com/woodchen-ink/proxy-go.git
synced 2025-07-18 08:31:55 +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"
|
||||
"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, "/")
|
||||
|
Loading…
x
Reference in New Issue
Block a user