package middleware import ( "confrontation-training/common" "confrontation-training/response" "github.com/gin-gonic/gin" ) func JwtAuth() gin.HandlerFunc { return func(context *gin.Context) { token := context.Request.Header.Get("token") if token == "" { response.Failed("非法访问", context) context.Abort() return } if err := common.VerifyToken(token); err != nil { response.Failed("登录已过期,请重新登录", context) context.Abort() return } context.Next() } }