framework1/framework/middleware/recovery.go

18 lines
294 B
Go

package middleware
import (
"github.com/Superdanda/hade/framework/gin"
"net/http"
)
func Recovery() gin.HandlerFunc {
return func(c *gin.Context) {
defer func() {
if err := recover(); err != nil {
c.ISetStatus(http.StatusInternalServerError).IJson(err)
}
}()
c.Next()
}
}