handler

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authorize

func Authorize(secret string, opts ...AuthorizeOption) func(http.Handler) http.Handler

Authorize returns an authorize middleware.

func BreakerHandler

func BreakerHandler(method, path string, metrics *stat.Metrics) func(http.Handler) http.Handler

BreakerHandler returns a break circuit middleware.

func ContentSecurityHandler

func ContentSecurityHandler(decrypters map[string]codec.RsaDecrypter, tolerance time.Duration,
	strict bool, callbacks ...UnsignedCallback) func(http.Handler) http.Handler

ContentSecurityHandler returns a middleware to verify content security.

func CryptionHandler

func CryptionHandler(key []byte) func(http.Handler) http.Handler

CryptionHandler returns a middleware to handle cryption.

func DetailedLogHandler

func DetailedLogHandler(next http.Handler) http.Handler

DetailedLogHandler returns a middleware that logs http request and response in details.

func GunzipHandler

func GunzipHandler(next http.Handler) http.Handler

GunzipHandler returns a middleware to gunzip http request body.

func LogHandler

func LogHandler(next http.Handler) http.Handler

LogHandler returns a middleware that logs http request and response.

func MaxBytesHandler

func MaxBytesHandler(n int64) func(http.Handler) http.Handler

MaxBytesHandler returns a middleware that limit reading of http request body.

func MaxConns

func MaxConns(n int) func(http.Handler) http.Handler

MaxConns returns a middleware that limit the concurrent connections.

func MetricHandler

func MetricHandler(metrics *stat.Metrics) func(http.Handler) http.Handler

MetricHandler returns a middleware that stat the metrics.

func PrometheusHandler

func PrometheusHandler(path string) func(http.Handler) http.Handler

PrometheusHandler returns a middleware that reports stats to prometheus.

func RecoverHandler

func RecoverHandler(next http.Handler) http.Handler

RecoverHandler returns a middleware that recovers if panic happens.

func SheddingHandler

func SheddingHandler(shedder load.Shedder, metrics *stat.Metrics) func(http.Handler) http.Handler

SheddingHandler returns a middleware that does load shedding.

func TimeoutHandler

func TimeoutHandler(duration time.Duration) func(http.Handler) http.Handler

TimeoutHandler returns the handler with given timeout.

func TracingHandler

func TracingHandler(next http.Handler) http.Handler

TracingHandler returns a middleware that traces the request.

Types

type AuthorizeOption

type AuthorizeOption func(opts *AuthorizeOptions)

AuthorizeOption defines the method to customize an AuthorizeOptions.

func WithPrevSecret

func WithPrevSecret(secret string) AuthorizeOption

WithPrevSecret returns an AuthorizeOption with setting previous secret.

func WithUnauthorizedCallback

func WithUnauthorizedCallback(callback UnauthorizedCallback) AuthorizeOption

WithUnauthorizedCallback returns an AuthorizeOption with setting unauthorized callback.

type AuthorizeOptions

type AuthorizeOptions struct {
	PrevSecret string
	Callback   UnauthorizedCallback
}

A AuthorizeOptions is authorize options.

type UnauthorizedCallback

type UnauthorizedCallback func(w http.ResponseWriter, r *http.Request, err error)

UnauthorizedCallback defines the method of unauthorized callback.

type UnsignedCallback

type UnsignedCallback func(w http.ResponseWriter, r *http.Request, next http.Handler, strict bool, code int)

UnsignedCallback defines the method of the unsigned callback.

Jump to

Keyboard shortcuts

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