Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Rate limiter padrão: 10 requests por segundo, burst de 20 DefaultRateLimiter = NewRateLimiter(10, 20, time.Minute*1) // Rate limiter mais restritivo: 2 requests por segundo, burst de 5 StrictRateLimiter = NewRateLimiter(2, 5, time.Minute*1) )
Instância global de rate limiter
Functions ¶
func DynamicVerifier ¶
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter gerencia rate limiters por IP
func NewRateLimiter ¶
func NewRateLimiter(requestsPerSecond float64, burstSize int, cleanupInterval time.Duration) *RateLimiter
NewRateLimiter cria um novo rate limiter
func (*RateLimiter) RateLimitMiddleware ¶
func (rl *RateLimiter) RateLimitMiddleware(next http.Handler) http.Handler
RateLimitMiddleware middleware para rate limiting por IP
func (*RateLimiter) RateLimitWithWait ¶
func (rl *RateLimiter) RateLimitWithWait(next http.Handler) http.Handler
RateLimitWithWait middleware que aguarda em vez de rejeitar
Click to show internal directories.
Click to hide internal directories.