This commit is contained in:
lwl0608 2024-03-21 20:18:22 +08:00
parent 6f16b754ce
commit ad95c1be67
3 changed files with 13 additions and 2 deletions

View File

@ -481,8 +481,6 @@ func ReplyJsonError(ctx *gin.Context, code int, msg string) {
}
func PrepareOp() gin.HandlerFunc {
defer logger.Recover()
return func(ctx *gin.Context) {
//if ctx.ClientIP() != "127.0.0.1" {
// ReplyJsonError(ctx, http.StatusBadRequest, fmt.Sprintf("not localhost, ip: %s", ctx.ClientIP()))

View File

@ -10,6 +10,7 @@ func NewRouter() *gin.Engine {
router := gin.New()
router.Use(middleware.LoggerMiddleware(gin.LoggerConfig{}))
router.Use(middleware.RecoverMiddleware())
return router
}

View File

@ -0,0 +1,12 @@
package middleware
import (
"github.com/gin-gonic/gin"
"service/library/logger"
)
func RecoverMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
defer logger.Recover()
}
}