@@ -5,9 +5,10 @@ import (
55 "NodePassDash/internal/auth"
66 "NodePassDash/internal/dashboard"
77 "NodePassDash/internal/endpoint"
8+ "NodePassDash/internal/group"
89 "NodePassDash/internal/metrics"
10+ "NodePassDash/internal/services"
911 "NodePassDash/internal/sse"
10- "NodePassDash/internal/group"
1112 "NodePassDash/internal/tunnel"
1213 "NodePassDash/internal/websocket"
1314 "fmt"
@@ -50,6 +51,7 @@ func setupAPIRoutes(r *gin.Engine, db *gorm.DB, sseService *sse.Service, sseMana
5051 endpointService := endpoint .NewService (db )
5152 tunnelService := tunnel .NewService (db )
5253 groupService := group .NewService (db )
54+ servicesService := services .NewService (db )
5355 dashboardService := dashboard .NewService (db )
5456
5557 // 创建 Metrics 系统相关的处理器
@@ -65,6 +67,7 @@ func setupAPIRoutes(r *gin.Engine, db *gorm.DB, sseService *sse.Service, sseMana
6567 api .SetupDashboardRoutes (apiGroup , dashboardService )
6668 api .SetupDataRoutes (apiGroup , db , sseManager , endpointService , tunnelService )
6769 api .SetupGroupRoutes (apiGroup , groupService )
70+ api .SetupServicesRoutes (apiGroup , servicesService )
6871 api .SetupVersionRoutes (apiGroup , version )
6972 api .SetupDebugRoutes (apiGroup )
7073 }
@@ -74,22 +77,22 @@ func setupAPIRoutes(r *gin.Engine, db *gorm.DB, sseService *sse.Service, sseMana
7477func docsProxyHandler (c * gin.Context ) {
7578 // 获取路径参数
7679 path := c .Param ("path" )
77-
80+
7881 // 构建目标 URL
7982 targetURL := fmt .Sprintf ("https://raw.githubusercontent.com%s" , path )
80-
83+
8184 // 创建 HTTP 客户端
8285 client := & http.Client {
8386 Timeout : 30 * time .Second ,
8487 }
85-
88+
8689 // 创建请求
8790 req , err := http .NewRequest (c .Request .Method , targetURL , c .Request .Body )
8891 if err != nil {
8992 c .JSON (http .StatusInternalServerError , gin.H {"error" : "创建请求失败" })
9093 return
9194 }
92-
95+
9396 // 复制请求头(排除某些不需要的头)
9497 for name , values := range c .Request .Header {
9598 if ! shouldSkipHeader (name ) {
@@ -98,15 +101,15 @@ func docsProxyHandler(c *gin.Context) {
98101 }
99102 }
100103 }
101-
104+
102105 // 发送请求
103106 resp , err := client .Do (req )
104107 if err != nil {
105108 c .JSON (http .StatusBadGateway , gin.H {"error" : "代理请求失败" })
106109 return
107110 }
108111 defer resp .Body .Close ()
109-
112+
110113 // 复制响应头
111114 for name , values := range resp .Header {
112115 if ! shouldSkipHeader (name ) {
@@ -115,10 +118,10 @@ func docsProxyHandler(c *gin.Context) {
115118 }
116119 }
117120 }
118-
121+
119122 // 设置状态码
120123 c .Status (resp .StatusCode )
121-
124+
122125 // 复制响应体
123126 _ , err = io .Copy (c .Writer , resp .Body )
124127 if err != nil {
@@ -139,7 +142,7 @@ func shouldSkipHeader(name string) bool {
139142 "Transfer-Encoding" ,
140143 "Upgrade" ,
141144 }
142-
145+
143146 for _ , skip := range skipHeaders {
144147 if strings .EqualFold (name , skip ) {
145148 return true
0 commit comments