framework1/framework/middleware/recovery.go

19 lines
319 B
Go
Raw Normal View History

2024-10-18 14:41:55 +08:00
package middleware
import (
"github.com/echo/hade/framework"
"net/http"
)
func Recovery() framework.ControllerHandler {
return func(c *framework.Context) error {
defer func() {
if err := recover(); err != nil {
c.SetStatus(http.StatusInternalServerError).Json(err)
}
}()
c.Next()
return nil
}
}