package middleware import ( "github.com/gin-gonic/gin" "log" "net/http" ) // Handler 异常处理 func Handler(c *gin.Context) { defer func() { if r := recover(); r != nil { log.Printf("panic: internal error: ") c.JSON(http.StatusInternalServerError, gin.H{ "message": "服务器内部异常", }) c.Abort() } }() c.Next() }