From 3c9b36cc07ea388142162daefe94e34f42f73af0 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sun, 18 May 2025 14:38:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9jwt=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 108440d..652b79f 100644 --- a/main.go +++ b/main.go @@ -111,17 +111,17 @@ func JWTAuthMiddleware() gin.HandlerFunc { if tokenString == "" { tokenString = c.Query("token") } - //for k, _ := range proto.Url_map { - // if strings.Contains(c.Request.URL.Path, k) { - // log.Println("need not check token:", c.Request.URL.Path) - // c.Next() - // return - // } - //} - if proto.Url_map[c.Request.URL.Path] == true { //查看是否在不需要token的url中 - c.Next() - return + for k, _ := range proto.Url_map { + if strings.Contains(c.Request.URL.Path, k) { + log.Println("need not check token:", c.Request.URL.Path) + c.Next() + return + } } + //if proto.Url_map[c.Request.URL.Path] == true { //查看是否在不需要token的url中 + // c.Next() + // return + //} if tokenString == "" { c.AbortWithStatusJSON(http.StatusOK, gin.H{"message": "unauthorized", "error": "token is empty", "code": proto.TokenIsNull}) return