httperr

package
v0.36.24 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

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.

Jump to

Keyboard shortcuts

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