Documentation
¶
Overview ¶
Package middleware provides HTTP middleware for ChronosOS.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CORS ¶
func CORS(cfg CORSConfig) func(http.Handler) http.Handler
CORS returns middleware that handles Cross-Origin Resource Sharing.
Types ¶
type CORSConfig ¶
type CORSConfig struct {
AllowOrigins []string
AllowMethods []string
AllowHeaders []string
ExposeHeaders []string
AllowCredentials bool
MaxAge int
}
CORSConfig holds CORS middleware configuration.
func DefaultCORSConfig ¶
func DefaultCORSConfig() CORSConfig
DefaultCORSConfig returns a permissive CORS config suitable for development.
type RateLimitConfig ¶
type RateLimitConfig struct {
RequestsPerWindow int
Window time.Duration
KeyFunc func(r *http.Request) string
}
RateLimitConfig holds configuration for the rate limiter.
func DefaultRateLimitConfig ¶
func DefaultRateLimitConfig() RateLimitConfig
DefaultRateLimitConfig returns a rate limiter that allows 100 requests per minute keyed by client IP.
Click to show internal directories.
Click to hide internal directories.