middleware

package
v0.0.0-...-86906c4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CSRFTokenCookieName = "__Host-csrf"
	CSRFTokenHeaderName = "x-csrf-token"
	CSRFTokenFieldName  = "_csrf"
)
View Source
const SessionCookieName = "__Host-session"

Variables

This section is empty.

Functions

func Apply

func Apply(handler http.Handler, middlewares ...Middleware) http.Handler

func ETag

func ETag(next http.HandlerFunc) http.HandlerFunc

func MethodOverride

func MethodOverride(next http.HandlerFunc) http.HandlerFunc

func NoContent

func NoContent(next http.HandlerFunc) http.HandlerFunc

func RemoveTrailingSlash

func RemoveTrailingSlash(next http.HandlerFunc) http.HandlerFunc

func SecurityHeaders

func SecurityHeaders(next http.HandlerFunc) http.HandlerFunc

Types

type CSRFConfig

type CSRFConfig struct {
	Insecure     bool
	ErrorHandler ErrorHandler
}

type ConsumeFunc

type ConsumeFunc func(r *http.Request) bool

type ErrorHandler

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

type Middleware

type Middleware func(next http.HandlerFunc) http.HandlerFunc

func CSRF

func CSRF(config *CSRFConfig) Middleware

func MaxBytes

func MaxBytes(maxBytes func(*http.Request) int) Middleware

func RateLimit

func RateLimit(capacity, replenish float64, config *RateLimitConfig) Middleware

func Recover

func Recover(errorHandler ErrorHandler) Middleware

func Session

func Session(sm *session.Manager, config *SessionConfig) Middleware

func Timeout

func Timeout(dt time.Duration, errorHandler ErrorHandler) Middleware

type RateLimitConfig

type RateLimitConfig struct {
	Consume        ConsumeFunc
	TrustedProxies []string
	ErrorHandler   ErrorHandler
}

type SessionConfig

type SessionConfig struct {
	Insecure     bool
	ErrorHandler ErrorHandler
}

Jump to

Keyboard shortcuts

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