handler

package
v0.0.0-...-8ce278b Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 38 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(fasthttp.RequestHandler) fasthttp.RequestHandler

Authorize returns an authorization middleware.

func BreakerHandler

func BreakerHandler(method, path string, metrics *stat.Metrics) func(fasthttp.RequestHandler) fasthttp.RequestHandler

BreakerHandler returns a break circuit middleware.

func ContentSecurityHandler

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

ContentSecurityHandler returns a middleware to verify content security.

func CryptionHandler

func CryptionHandler(key []byte) func(fasthttp.RequestHandler) fasthttp.RequestHandler

CryptionHandler returns a middleware to handle cryption.

func DetailedLogHandler

func DetailedLogHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler

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

func GunzipHandler

func GunzipHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler

GunzipHandler returns a middleware to gunzip http request body.

func LimitContentSecurityHandler

func LimitContentSecurityHandler(limitBytes int64, decrypters map[string]codec.RsaDecrypter,
	tolerance time.Duration, strict bool, callbacks ...UnsignedCallback) func(handler fasthttp.RequestHandler) fasthttp.RequestHandler

LimitContentSecurityHandler returns a middleware to verify content security.

func LimitCryptionHandler

func LimitCryptionHandler(limitBytes int64, key []byte) func(handler fasthttp.RequestHandler) fasthttp.RequestHandler

LimitCryptionHandler returns a middleware to handle cryption.

func LogHandler

LogHandler returns a middleware that logs http request and response.

func MaxBytesHandler

func MaxBytesHandler(n int64) func(fasthttp.RequestHandler) fasthttp.RequestHandler

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

func MaxConnsHandler

func MaxConnsHandler(n int) func(fasthttp.RequestHandler) fasthttp.RequestHandler

MaxConnsHandler returns a middleware that limit the concurrent connections.

func MetricHandler

func MetricHandler(metrics *stat.Metrics) func(fasthttp.RequestHandler) fasthttp.RequestHandler

MetricHandler returns a middleware that stat the metrics.

func PrometheusHandler

func PrometheusHandler(path, method string) func(fasthttp.RequestHandler) fasthttp.RequestHandler

PrometheusHandler returns a middleware that reports stats to prometheus.

func RecoverHandler

func RecoverHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler

RecoverHandler returns a middleware that recovers if panic happens.

func SetSlowThreshold

func SetSlowThreshold(threshold time.Duration)

SetSlowThreshold sets the slow threshold.

func SheddingHandler

func SheddingHandler(shedder load.Shedder, metrics *stat.Metrics) func(fasthttp.RequestHandler) fasthttp.RequestHandler

SheddingHandler returns a middleware that does load shedding.

func TimeoutHandler

func TimeoutHandler(duration time.Duration) func(fasthttp.RequestHandler) fasthttp.RequestHandler

TimeoutHandler returns the handler with given timeout. If client closed request, code 499 will be logged. Notice: even if canceled in server side, 499 will be logged as well.

func TraceHandler

func TraceHandler(serviceName, path string, opts ...TraceOption) func(handler fasthttp.RequestHandler) fasthttp.RequestHandler

TraceHandler return a middleware that process the opentelemetry.

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
}

An AuthorizeOptions is authorize options.

type TraceOption

type TraceOption func(options *traceOptions)

TraceOption defines the method to customize an traceOptions.

func WithTraceIgnorePaths

func WithTraceIgnorePaths(traceIgnorePaths []string) TraceOption

WithTraceIgnorePaths specifies the traceIgnorePaths option for TraceHandler.

type UnauthorizedCallback

type UnauthorizedCallback func(ctx *fasthttp.RequestCtx, err error)

UnauthorizedCallback defines the method of unauthorized callback.

type UnsignedCallback

type UnsignedCallback func(ctx *fasthttp.RequestCtx, next fasthttp.RequestHandler, 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