19 lines
319 B
Go
19 lines
319 B
Go
|
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
|
||
|
}
|
||
|
}
|