fix: lint issues

This commit is contained in:
yanghao05
2023-03-09 10:23:23 +08:00
parent 8d1bd191df
commit 5943b9e1d5
17 changed files with 88 additions and 78 deletions

View File

@@ -50,11 +50,9 @@ func CorsByRules(config *config.Config) gin.HandlerFunc {
// 严格白名单模式且未通过检查,直接拒绝处理请求
if whitelist == nil && config.Http.Cors.Mode == "strict-whitelist" && !(c.Request.Method == "GET" && c.Request.URL.Path == "/health") {
c.AbortWithStatus(http.StatusForbidden)
} else {
} else if c.Request.Method == http.MethodOptions {
// 非严格白名单模式,无论是否通过检查均放行所有 OPTIONS 方法
if c.Request.Method == http.MethodOptions {
c.AbortWithStatus(http.StatusNoContent)
}
c.AbortWithStatus(http.StatusNoContent)
}
// 处理请求