diff --git a/middleware/recovery/middleware.go b/middleware/recovery/middleware.go index 1c522d9..eb1b75d 100644 --- a/middleware/recovery/middleware.go +++ b/middleware/recovery/middleware.go @@ -59,18 +59,12 @@ func recoveryError(code int, c *gin.Context) map[string]interface{} { func RecoveryHttpError(code int) gin.HandlerFunc { return func(c *gin.Context) { - defer func() { - if err := recover(); err != nil { - info := recoveryError(code, c) - if strings.HasPrefix(c.Request.URL.Path, "/api") { - c.JSON(code, gin.H(info)) - } else { - c.HTML(code, "page_404.html", template.Context(info)) - } - c.Abort() - } - }() - c.Next() + info := recoveryError(code, c) + if strings.HasPrefix(c.Request.URL.Path, "/api") { + c.JSON(code, gin.H(info)) + } else { + c.HTML(code, "page_404.html", template.Context(info)) + } } } func RecoveryJSON() gin.HandlerFunc {