error

package
v0.0.0-...-006488c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

HTML is the standard PlainText error handler.

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.

func (*HTTPErrorLogger) Error

func (l *HTTPErrorLogger) Error(req *http.Request, statusCode int, logMessage string, dev *DevInfo)

Error logs at ERROR level.

func (*HTTPErrorLogger) Info

func (l *HTTPErrorLogger) Info(req *http.Request, statusCode int, logMessage string, dev *DevInfo)

Info logs at INFO level.

func (*HTTPErrorLogger) Panic

func (l *HTTPErrorLogger) Panic(req *http.Request, statusCode int, logMessage string, dev *DevInfo)

Panic logs at PANIC level. Ignores any panics the logger calls.

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

func (h *Handler) GetRecoverer() Recoverer

GetRecoverer returns a new Recoverer.

func (*Handler) InternalServerError

func (h *Handler) InternalServerError(w http.ResponseWriter, req *http.Request, err error)

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

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL