handler

package
v0.0.0-...-8540621 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error interface {
	error
	Status() int
}

Error represents a handler error. It provides methods for a HTTP status code and embeds the built-in error interface.

type Handler

type Handler struct {
	H func(e env.Env, w http.ResponseWriter, r *http.Request) error
	// contains filtered or unexported fields
}

Handler struct that takes a configured BaseEnv and a function matching our signature.

func New

func New(e env.Env, f func(e env.Env, w http.ResponseWriter, r *http.Request) error) *Handler

New returns a new App handler.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows our Handler type to satisfy http.Handler.

type StatusError

type StatusError struct {
	Code int
	Err  error
}

StatusError represents an error with an associated HTTP status code.

func NewStatusError

func NewStatusError(code int, msg string) *StatusError

NewStatusError creates a new status error with a code and msg.

func (StatusError) Error

func (se StatusError) Error() string

Error returns the status errors underlying error.

func (StatusError) Status

func (se StatusError) Status() int

Status returns the HTTP status code.

Jump to

Keyboard shortcuts

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