Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCSRF ¶
func WithCSRF(cfg CSRFConfig, next http.HandlerFunc) http.HandlerFunc
WithCSRF wraps an http.HandlerFunc with CSRF validation logic. If CSRF is disabled, the handler is executed directly. If validation fails, it responds with the same payload used previously in the handlers and does not call the wrapped handler.
func WithRateLimit ¶
func WithRateLimit(cfg RateLimitConfig, next http.HandlerFunc) http.HandlerFunc
WithRateLimit wraps an http.HandlerFunc with rate limiting logic.
Types ¶
type CSRFConfig ¶
CSRFConfig holds configuration for CSRF validation.
type RateLimitConfig ¶
type RateLimitConfig struct {
// Check should perform the actual rate limit check. It should return true if
// the request is allowed to proceed. If it returns false, it is assumed to
// have already written the appropriate HTTP response.
Check func(w http.ResponseWriter, r *http.Request, endpoint string) bool
// Endpoint is the logical endpoint name used for rate limiting, e.g.
// "login", "register", etc.
Endpoint string
}
RateLimitConfig holds configuration for rate limiting.
Click to show internal directories.
Click to hide internal directories.