This commit is contained in:
ljw
2024-09-13 15:57:29 +08:00
commit c53df223d1
112 changed files with 14353 additions and 0 deletions

20
http/middleware/logger.go Normal file
View File

@@ -0,0 +1,20 @@
package middleware
import (
"Gwen/global"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
// Logger 日志中间件
func Logger() gin.HandlerFunc {
return func(c *gin.Context) {
global.Logger.WithFields(
logrus.Fields{
"uri": c.Request.URL,
"ip": c.ClientIP(),
"method": c.Request.Method,
}).Debug("Request")
c.Next()
}
}