middlewares

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorLogger

func ErrorLogger(next http.Handler) http.Handler

ErrorLogger is a middleware that logs http errors.

func Logger

func Logger(next http.Handler) http.Handler

Logger is a middleware that logs the start and end of each request.

func Recoverer

func Recoverer(next http.Handler) http.Handler

Recoverer is a middleware that recovers from panics, logs the panic (and a backtrace), and returns a HTTP 500 (Internal Server Error) status if possible.

Types

type RateLimit

type RateLimit struct {
	Limiter        *limiter.Limiter
	OnError        stdlib.ErrorHandler
	OnLimitReached stdlib.LimitReachedHandler
}

func NewRateLimit

func NewRateLimit(opts RateLimitOpts) *RateLimit

func (*RateLimit) Handle

func (middleware *RateLimit) Handle(next http.Handler) http.HandlerFunc

type RateLimitOpts

type RateLimitOpts struct {
	Period time.Duration
	Limit  int64
}

Jump to

Keyboard shortcuts

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