Documentation
¶
Index ¶
- func DefaultKeyFunc(r *http.Request) string
- func FeatureGuard(featureKey string, next http.Handler) http.Handler
- func FeatureGuardFunc(featureKey string, next func(http.ResponseWriter, *http.Request)) http.Handler
- func RequireFeature(featureKeys ...string) func(http.Handler) http.Handler
- func RequireTier(minimumTier core.Tier, next http.Handler) http.Handler
- func TierBasedResponse(next http.Handler) http.Handler
- type RateLimitConfig
- type RateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultKeyFunc ¶
DefaultKeyFunc generates a rate limit key from the request
func FeatureGuard ¶
FeatureGuard middleware checks if the current license tier allows access to a feature
func FeatureGuardFunc ¶
func FeatureGuardFunc(featureKey string, next func(http.ResponseWriter, *http.Request)) http.Handler
FeatureGuardFunc is a convenience wrapper for http.HandlerFunc
func RequireFeature ¶
RequireFeature checks if a specific feature is available
func RequireTier ¶
RequireTier ensures the request comes from an account with minimum tier
Types ¶
type RateLimitConfig ¶
type RateLimitConfig struct {
RequestsPerMinute int
Burst int
BlockDuration time.Duration
KeyFunc func(r *http.Request) string
}
RateLimitConfig holds rate limiting configuration
func DefaultRateLimitConfig ¶
func DefaultRateLimitConfig(tier core.Tier) RateLimitConfig
DefaultRateLimitConfig returns default configuration based on tier
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements per-client rate limiting using token bucket
func NewRateLimiter ¶
func NewRateLimiter(config RateLimitConfig) *RateLimiter
NewRateLimiter creates a new rate limiter with the given configuration
func (*RateLimiter) Middleware ¶
func (rl *RateLimiter) Middleware(next http.Handler) http.Handler
Middleware returns a middleware that applies rate limiting