middleware

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Intercept

func Intercept(next http.Handler) http.Handler

Intercept attaches the chi response wrapper

Types

type AccessLog

type AccessLog struct {
	// contains filtered or unexported fields
}

AccessLog implements the middleware interface

func NewAccessLog

func NewAccessLog(logger *zap.Logger, extraHeader string) *AccessLog

NewAccessLog creates a new middleware which prints access logs

func (*AccessLog) Wrap

func (a *AccessLog) Wrap(next http.Handler) http.Handler

Wrap implements the middleware interface

type Instrument

type Instrument struct {
	// contains filtered or unexported fields
}

Instrument is a middleware which creates a request duration historgram for every incoming HTTP request

func NewInstrument

func NewInstrument(metricsNamespace string) *Instrument

NewInstrument creates a prometheus preinitialized instance which then can be used to bind a middleware to a router

func (*Instrument) Wrap

func (i *Instrument) Wrap(next http.Handler) http.Handler

Wrap implements the middleware interface

type Interface

type Interface interface {
	Wrap(http.Handler) http.Handler
}

Interface is the shared contract for all middlesware, and allows middlesware to wrap handlers.

type Recoverer

type Recoverer struct {
	Logger *zap.Logger
}

Recoverer middleware logs unhandled panics and tries to continue running the API

func (*Recoverer) Wrap

func (rec *Recoverer) Wrap(next http.Handler) http.Handler

Wrap provides the actual middleware for recovering from panic

Jump to

Keyboard shortcuts

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