Documentation ¶
Overview ¶
Package recoverer provides an http middleware to catch and log panics, and optionally display a text (or html) page with the details (useful when one is debugging or has a debug flag enabled). recoverer will also show exported expvar variables in html mode.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRecoverer ¶
DefaultRecoverer provides sane defaults to catch and log the panic to stderr, and throwing a generic 500 error back to the http client. See New() to specify custom options.
Types ¶
type LeveledLogger ¶
type LeveledLogger interface {
Error(msg string)
}
LeveledLogger is a logger that supports different levels (primarily ERROR).
type LeveledLoggerWriter ¶
type LeveledLoggerWriter struct {
Logger LeveledLogger
}
LeveledLoggerWriter can be used to convert a *log.Logger to an io.Writer.
type LoggerWriter ¶
type LoggerWriter struct {
Logger StdLogger
}
LoggerWriter can be used to convert a *log.Logger to an io.Writer.
type Options ¶
type Options struct { // Logger is an optional io.Writer which the panic error and stack trace // are written to. Logger io.Writer // Show renders the panic and stack trace from the handler. Show bool // Simple renders the panic and stack trace in plain text, rather than // the default of HTML. Simple bool // Fn is a function which is called before the panic is written back to // the connection (useful if you want, for example, to increment the // total number of exceptions for a service, or if you want to only show // the error to a specific set of IP's). If the returned error is not nil, // the recoverer will not show the error back to the end user, and the // error will be logged. recoverer WILL NOT prevent this function from // panicing. Fn func(req *http.Request, err interface{}, file string, line int) error }
Options is the configuration which you can pass to the recoverer, to allow showing/hiding stack, etc.