Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthMiddleware ¶
type AuthMiddleware struct {
// contains filtered or unexported fields
}
func NewAuthMiddleware ¶
func NewAuthMiddleware(p AuthMiddlewareParams) *AuthMiddleware
func (*AuthMiddleware) Authenticate ¶
func (m *AuthMiddleware) Authenticate() fiber.Handler
Authenticate middleware validates the session and refreshes it if needed
type AuthMiddlewareParams ¶
type LogConfig ¶
type LogConfig struct { // Skip defines a function to skip middleware execution Skip func(c *fiber.Ctx) bool // Custom logging tags CustomTags map[string]string // Minimum duration to log as slow request (default: 500ms) SlowRequestThreshold time.Duration // Log request body (default: false due to security and performance) LogRequestBody bool // Log response body (default: false due to security and performance) LogResponseBody bool // Maximum body size to log (default: 1024 bytes) MaxBodySize int // List of headers to log (default: empty) LogHeaders []string // Paths to exclude from logging (e.g., health checks, metrics) ExcludePaths []string }
LogConfig holds the configuration for the logging middleware
func DefaultLogConfig ¶
func DefaultLogConfig() LogConfig
DefaultLogConfig returns a default configuration for the logging middleware
type RateLimitConfig ¶
type RateLimitConfig struct { MaxRequests int // Maximum number of requests allowed in the interval Interval time.Duration // Time window for rate limiting KeyPrefix string // Optional prefix for Redis keys Skip func(*fiber.Ctx) bool // Optional function to skip rate limiting }
RateLimitConfig defines the configuration for rate limiting
func Every ¶
func Every(n int, t time.Duration) RateLimitConfig
Every creates a rate limit configuration for requests over a custom duration
func PerHour ¶
func PerHour(n int) RateLimitConfig
PerHour creates a rate limit configuration for requests per hour
func PerMinute ¶
func PerMinute(n int) RateLimitConfig
PerMinute creates a rate limit configuration for requests per minute
func PerSecond ¶
func PerSecond(n int) RateLimitConfig
PerSecond creates a rate limit configuration for requests per second
type RateLimitParams ¶
type RateLimitParams struct { Logger *logger.Logger // Logger instance for recording rate limit events Redis *redis.Client // Redis client for storing rate limit data }
RateLimitParams defines the dependencies required for rate limiting
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter manages rate limiting functionality
func NewRateLimit ¶
func NewRateLimit(p RateLimitParams) *RateLimiter
NewRateLimit creates a new rate limiter instance with the provided dependencies
func (*RateLimiter) WithRateLimit ¶
func (rl *RateLimiter) WithRateLimit(handlers []fiber.Handler, config RateLimitConfig) []fiber.Handler
WithRateLimit wraps the provided handlers with rate limiting middleware Returns a slice of handlers with rate limiting applied