middlewares

package
v1.0.156 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 6 Imported by: 0

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

func DynamicVerifier(authFunc func() *jwtauth.JWTAuth) func(http.Handler) http.Handler

func RateLimit

func RateLimit() func(http.Handler) http.Handler

Middlewares prontos para uso

func RateLimitWithWait

func RateLimitWithWait() func(http.Handler) http.Handler

func StrictRateLimit

func StrictRateLimit() func(http.Handler) http.Handler

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL