优化代码格式

This commit is contained in:
user123456
2025-07-27 10:58:20 +08:00
parent 1881b5b1ba
commit 07a926902a
12 changed files with 94 additions and 111 deletions

View File

@@ -36,7 +36,7 @@ func GitHubProxyHandler(c *gin.Context) {
for strings.HasPrefix(rawPath, "/") {
rawPath = strings.TrimPrefix(rawPath, "/")
}
// 自动补全协议头
if !strings.HasPrefix(rawPath, "https://") {
if strings.HasPrefix(rawPath, "http:/") || strings.HasPrefix(rawPath, "https:/") {
@@ -47,7 +47,7 @@ func GitHubProxyHandler(c *gin.Context) {
}
rawPath = "https://" + rawPath
}
matches := CheckGitHubURL(rawPath)
if matches != nil {
if allowed, reason := utils.GlobalAccessController.CheckGitHubAccess(matches); !allowed {
@@ -96,7 +96,7 @@ func proxyGitHubWithRedirect(c *gin.Context, u string, redirectCount int) {
c.String(http.StatusLoopDetected, "重定向次数过多,可能存在循环重定向")
return
}
req, err := http.NewRequest(c.Request.Method, u, c.Request.Body)
if err != nil {
c.String(http.StatusInternalServerError, fmt.Sprintf("server error %v", err))
@@ -210,4 +210,4 @@ func proxyGitHubWithRedirect(c *gin.Context, u string, redirectCount int) {
// 直接流式转发
io.Copy(c.Writer, resp.Body)
}
}
}