Documentation
¶
Index ¶
- Constants
- func DefaultAllowedHeaders() []string
- func DefaultAllowedMethods() []string
- func NewBasicAuth(username, password string) ctx.Handler
- func NewCors(options CorsOptions) ctx.Handler
- func NewLog(l loggerService) ctx.Handler
- func NewRateLimit(cfg RateLimitConfig) ctx.Handler
- func NewRecovery() ctx.Handler
- func NewSecurityHeaders() ctx.Handler
- func NewSession(cacheSvc cache.Service, autostart bool) ctx.Handler
- func NewTimeout(d time.Duration) ctx.Handler
- func StartSession(c ctx.Ctx, cacheSvc cache.Service) error
- type CorsOptions
- type RateLimitConfig
Constants ¶
View Source
const ( SessionAutoStart bool = true NoSessionAutoStart bool = false )
Variables ¶
This section is empty.
Functions ¶
func DefaultAllowedHeaders ¶
func DefaultAllowedHeaders() []string
func DefaultAllowedMethods ¶
func DefaultAllowedMethods() []string
func NewBasicAuth ¶
func NewCors ¶
func NewCors(options CorsOptions) ctx.Handler
func NewRateLimit ¶
func NewRateLimit(cfg RateLimitConfig) ctx.Handler
NewRateLimit returns a middleware that limits requests per IP address using a fixed-window counter algorithm.
func NewRecovery ¶
NewRecovery returns a middleware that recovers from panics in downstream handlers and converts them into a 500 Internal Server Error response.
func NewSecurityHeaders ¶
NewSecurityHeaders adds common security headers to all responses.
func NewTimeout ¶
NewTimeout returns a middleware that cancels the request context after the given duration. If the handler exceeds the deadline, a 503 Service Unavailable error is returned.
Types ¶
type CorsOptions ¶
func NewCorsOptions ¶
func NewCorsOptions() CorsOptions
type RateLimitConfig ¶
type RateLimitConfig struct {
// Maximum number of requests allowed within the window
Max int
// Time window for counting requests
Window time.Duration
// CleanupInterval controls how often expired entries are removed.
// Defaults to 2x Window if zero.
CleanupInterval time.Duration
}
RateLimitConfig configures the rate limiter.
func DefaultRateLimitConfig ¶
func DefaultRateLimitConfig() RateLimitConfig
DefaultRateLimitConfig returns a config allowing 60 requests per minute.
Click to show internal directories.
Click to hide internal directories.