Documentation

Overview

    Package httperr contains some helpers for nicer error handling in http.Handler implementations.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func New

    func New(code int, msg string) error

      New returns a Responder that emits the given HTTP status code and message.

      func Newf

      func Newf(code int, format string, args ...interface{}) error

        Newf returns a Responder that emits the given HTTP status code and fmt.Sprintf formatted message.

        func Wrap

        func Wrap(code int, msg string, cause error) error

          Wrap returns a Responder that emits the given HTTP status code and message, and also wraps an internal error.

          Types

          type HandlerFunc

          type HandlerFunc func(http.ResponseWriter, *http.Request) error

            HandlerFunc is like http.HandlerFunc, but with a function signature that allows easier error handling.

            func (HandlerFunc) ServeHTTP

            func (f HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

            type Responder

            type Responder interface {
            	error
            	Respond(http.ResponseWriter)
            }

              Responder represents an error that can emit a useful HTTP error response to an http.ResponseWriter.

              Source Files