handlerutil

package
v0.0.0-...-19239a5 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: EUPL-1.2 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(handler func(http.ResponseWriter, *http.Request) error) func(http.ResponseWriter, *http.Request)

func ErrorRecovery

func ErrorRecovery(next http.Handler) http.Handler

func GracefulShutdown

func GracefulShutdown(srv *http.Server, timeout time.Duration)

GracefulShutdown shuts down the given HTTP server gracefully when receiving an os.Interrupt or syscall.SIGTERM signal. It will wait for the specified timeout to stop hanging HTTP handlers.

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

func RequestIdMiddleware

func RequestIdMiddleware(next http.Handler) http.Handler

func RespondWithJSON

func RespondWithJSON(res http.ResponseWriter, code int, payload interface{})

Types

type HttpError

type HttpError struct {
	StatusCode int
	Message    string
	Detail     error
}

func NewAuthorizationError

func NewAuthorizationError(message string) *HttpError

func NewBadRequestError

func NewBadRequestError(message string) *HttpError

func NewFailedDependencyError

func NewFailedDependencyError(message string) *HttpError

func NewForbiddenError

func NewForbiddenError(message string) *HttpError

func NewNotFoundError

func NewNotFoundError(message string) *HttpError

func NewTooManyRequestsError

func NewTooManyRequestsError(message string) *HttpError

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) WithDetail

func (e *HttpError) WithDetail(err error) *HttpError

Jump to

Keyboard shortcuts

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