package middleware import ( "github.com/anxpp/common-utils/logg" "github.com/anxpp/common-utils/net" "github.com/gin-gonic/gin" "net/http" "net/url" ) func Authorize() gin.HandlerFunc { return func(c *gin.Context) { inputToken := c.Request.Header.Get("X-Token") if len(inputToken) == 0 { c.JSON(http.StatusOK, net.Custom(500, "缺少授权token")) c.Abort() } c.Next() } } func LogRequest() gin.HandlerFunc { return func(c *gin.Context) { decodedStr, _ := url.QueryUnescape(c.Request.RequestURI) logg.Info("request:", c.Request.RemoteAddr, decodedStr) c.Next() } }