first commit

This commit is contained in:
Yangtao
2025-11-18 17:48:20 +08:00
commit 6e56cab848
196 changed files with 65809 additions and 0 deletions

View File

@ -0,0 +1,30 @@
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()
}
}