初次提交

This commit is contained in:
liuzhihang1
2024-06-26 20:45:23 +08:00
parent 4b388a5be1
commit 831ea9889f
57 changed files with 3945 additions and 0 deletions

26
route/middle/panic.go Normal file
View File

@@ -0,0 +1,26 @@
package middle
import (
"msm/consts/ctxflag"
"github.com/gin-gonic/gin"
)
func PanicMiddle() gin.HandlerFunc {
return func(c *gin.Context) {
defer func() {
if err := recover(); err == 0 {
if err, ok := c.Get(ctxflag.ERR); ok {
rErr(c, -1, err.(error).Error(), err.(error))
} else {
rErr(c, -1, "内部错误", nil)
}
} else {
if err != nil {
panic(err)
}
}
}()
c.Next()
}
}