Documentation ¶
Index ¶
- func Authorize(secret string, opts ...AuthorizeOption) func(http.Handler) http.Handler
- func BreakerHandler(method, path string, metrics *stat.Metrics) func(http.Handler) http.Handler
- func ContentSecurityHandler(decrypters map[string]codec.RsaDecrypter, tolerance time.Duration, strict bool, ...) func(http.Handler) http.Handler
- func CryptionHandler(key []byte) func(http.Handler) http.Handler
- func DetailedLogHandler(next http.Handler) http.Handler
- func GunzipHandler(next http.Handler) http.Handler
- func LimitContentSecurityHandler(limitBytes int64, decrypters map[string]codec.RsaDecrypter, ...) func(http.Handler) http.Handler
- func LimitCryptionHandler(limitBytes int64, key []byte) func(http.Handler) http.Handler
- func LogHandler(next http.Handler) http.Handler
- func MaxBytesHandler(n int64) func(http.Handler) http.Handler
- func MaxConnsHandler(n int) func(http.Handler) http.Handler
- func MetricHandler(metrics *stat.Metrics) func(http.Handler) http.Handler
- func PrometheusHandler(path string) func(http.Handler) http.Handler
- func RecoverHandler(next http.Handler) http.Handler
- func SetSlowThreshold(threshold time.Duration)
- func SheddingHandler(shedder load.Shedder, metrics *stat.Metrics) func(http.Handler) http.Handler
- func TimeoutHandler(duration time.Duration) func(http.Handler) http.Handler
- func TraceHandler(serviceName, path string, opts ...TraceOption) func(http.Handler) http.Handler
- type AuthorizeOption
- type AuthorizeOptions
- type TraceOption
- type UnauthorizedCallback
- type UnsignedCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BreakerHandler ¶
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 ¶
CryptionHandler returns a middleware to handle cryption.
func DetailedLogHandler ¶
DetailedLogHandler returns a middleware that logs http request and response in details.
func GunzipHandler ¶
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(http.Handler) http.Handler
LimitContentSecurityHandler returns a middleware to verify content security.
func LimitCryptionHandler ¶
LimitCryptionHandler returns a middleware to handle cryption.
func LogHandler ¶
LogHandler returns a middleware that logs http request and response.
func MaxBytesHandler ¶
MaxBytesHandler returns a middleware that limit reading of http request body.
func MaxConnsHandler ¶
MaxConnsHandler returns a middleware that limit the concurrent connections.
func MetricHandler ¶
MetricHandler returns a middleware that stat the metrics.
func PrometheusHandler ¶
PrometheusHandler returns a middleware that reports stats to prometheus.
func RecoverHandler ¶
RecoverHandler returns a middleware that recovers if panic happens.
func SetSlowThreshold ¶
SetSlowThreshold sets the slow threshold.
func SheddingHandler ¶
SheddingHandler returns a middleware that does load shedding.
func TimeoutHandler ¶
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 ¶
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(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.