Documentation ¶
Index ¶
- Constants
- func Apply(handler http.Handler, middlewares ...Middleware) http.Handler
- func ETag(next http.HandlerFunc) http.HandlerFunc
- func MethodOverride(next http.HandlerFunc) http.HandlerFunc
- func NoContent(next http.HandlerFunc) http.HandlerFunc
- func RemoveTrailingSlash(next http.HandlerFunc) http.HandlerFunc
- func SecurityHeaders(next http.HandlerFunc) http.HandlerFunc
- type CSRFConfig
- type ConsumeFunc
- type ErrorHandler
- type Middleware
- func CSRF(config *CSRFConfig) Middleware
- func MaxBytes(maxBytes func(*http.Request) int) Middleware
- func RateLimit(capacity, replenish float64, config *RateLimitConfig) Middleware
- func Recover(errorHandler ErrorHandler) Middleware
- func Session(sm *session.Manager, config *SessionConfig) Middleware
- func Timeout(dt time.Duration, errorHandler ErrorHandler) Middleware
- type RateLimitConfig
- type SessionConfig
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 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 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 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 }
Click to show internal directories.
Click to hide internal directories.