Documentation ¶
Overview ¶
Package fault provides a panic and error handler for the ozzo routing package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Recovery ¶
func Recovery(log LogFunc) routing.Handler
Recovery returns a handler that handles panics and errors occurred while servicing an HTTP request.
The handler will recover from panics and render the recovered error or the error returned by a handler. If the error is not a routing.HTTPError, it will respond with http.StatusInternalServerError. Otherwise, it will use the status code of the HTTPError.
A log function can be provided to log a message whenever an error is handled. If nil, no message will be logged.
import ( "log" "github.com/go-ozzo/ozzo-routing" "github.com/go-ozzo/ozzo-routing/fault" ) r := routing.New() r.Use(fault.Recovery(log.Printf))
Types ¶
Click to show internal directories.
Click to hide internal directories.