recover
This commit is contained in:
parent
6f16b754ce
commit
ad95c1be67
|
@ -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()))
|
||||
|
|
|
@ -10,6 +10,7 @@ func NewRouter() *gin.Engine {
|
|||
|
||||
router := gin.New()
|
||||
router.Use(middleware.LoggerMiddleware(gin.LoggerConfig{}))
|
||||
router.Use(middleware.RecoverMiddleware())
|
||||
|
||||
return router
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue