Documentation ¶
Index ¶
- Variables
- type DevInfo
- type ErrorPageGenerator
- type HTMLErrorPageGenerator
- type HTTPErrorLogger
- type Handler
- func (h *Handler) Error(w http.ResponseWriter, req *http.Request, statusCode int, ...)
- func (h *Handler) GetMethodNotAllowedHandler() MethodNotAllowedHandler
- func (h *Handler) GetNotFoundHandler() NotFoundHandler
- func (h *Handler) GetRecoverer() Recoverer
- func (h *Handler) InternalServerError(w http.ResponseWriter, req *http.Request, err error)
- type MethodNotAllowedHandler
- type NotFoundHandler
- type PlainErrorPageGenerator
- type Recoverer
Constants ¶
This section is empty.
Variables ¶
var HTML = NewHandler(HTMLErrorPageGenerator{})
HTML is the standard PlainText error handler.
var Plain = NewHandler(PlainErrorPageGenerator{})
Plain is the standard PlainText error handler.
Functions ¶
This section is empty.
Types ¶
type DevInfo ¶
type DevInfo struct {
// contains filtered or unexported fields
}
DevInfo contains development information that is passed to error handlers in development mode only.
type ErrorPageGenerator ¶
type ErrorPageGenerator interface { // SendError responds to the request with a page to display the error. SendError(w http.ResponseWriter, req *http.Request, statusCode int, statusMessage string, dev *DevInfo) }
ErrorPageGenerator is the interface that defines how error is sent to the client. TODO find a good name for this.
type HTMLErrorPageGenerator ¶
type HTMLErrorPageGenerator struct{}
HTMLErrorPageGenerator generates a HTML error page using the error template.
func (HTMLErrorPageGenerator) SendError ¶
func (HTMLErrorPageGenerator) SendError(w http.ResponseWriter, req *http.Request, statusCode int, statusMessage string, dev *DevInfo)
SendError responds to the request with a page to display the error.
type HTTPErrorLogger ¶
type HTTPErrorLogger struct {
// contains filtered or unexported fields
}
HTTPErrorLogger formats and logs HTTP errors to the given log.
type Handler ¶
type Handler struct { Generator ErrorPageGenerator Logger HTTPErrorLogger }
Handler is a error handler that defines how the error is logged and the client is sent the error.
func NewHandler ¶
func NewHandler(g ErrorPageGenerator) *Handler
NewHandler returns a new Handler using the standard logger.
func NewHandlerWithLogger ¶
func NewHandlerWithLogger(g ErrorPageGenerator, logger HTTPErrorLogger) *Handler
NewHandlerWithLogger returns a new Handler using the given logger.
func (*Handler) Error ¶
func (h *Handler) Error(w http.ResponseWriter, req *http.Request, statusCode int, statusMessage, logMessage string)
Error sends a error message to the client and logs the error.
func (*Handler) GetMethodNotAllowedHandler ¶
func (h *Handler) GetMethodNotAllowedHandler() MethodNotAllowedHandler
GetMethodNotAllowedHandler returns a new MethodNotAllowedHandler.
func (*Handler) GetNotFoundHandler ¶
func (h *Handler) GetNotFoundHandler() NotFoundHandler
GetNotFoundHandler returns a new NotFoundHandler.
func (*Handler) GetRecoverer ¶
GetRecoverer returns a new Recoverer.
func (*Handler) InternalServerError ¶
InternalServerError sends an InternalServerError error message to the client and logs the error.
type MethodNotAllowedHandler ¶
type MethodNotAllowedHandler struct {
// contains filtered or unexported fields
}
MethodNotAllowedHandler is a handler of Method Not Allowed errors that implements http.Handler.
func (MethodNotAllowedHandler) ServeHTTP ¶
func (h MethodNotAllowedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type NotFoundHandler ¶
type NotFoundHandler struct {
// contains filtered or unexported fields
}
NotFoundHandler a handler of Not Found errors that implements http.Handler.
func (NotFoundHandler) ServeHTTP ¶
func (h NotFoundHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type PlainErrorPageGenerator ¶
type PlainErrorPageGenerator struct{}
PlainErrorPageGenerator generates a plain text error page using the error template.
func (PlainErrorPageGenerator) SendError ¶
func (PlainErrorPageGenerator) SendError(w http.ResponseWriter, req *http.Request, statusCode int, statusMessage string, dev *DevInfo)
SendError responds to the request with a page to display the error.
type Recoverer ¶
type Recoverer struct {
// contains filtered or unexported fields
}
Recoverer is middleware that recovers from panics that occur in future handlers. It implements negroni.Handler.
func (Recoverer) ServeHTTP ¶
func (rec Recoverer) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)