middleware

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RateLimitMiddleware

func RateLimitMiddleware(l *LocalLimiter, keyFn func(*http.Request) string) func(http.Handler) http.Handler

Types

type LocalLimiter

type LocalLimiter struct {
	// contains filtered or unexported fields
}

func NewLocalLimiter

func NewLocalLimiter(policy RatePolicy) *LocalLimiter

func (*LocalLimiter) Allow

func (l *LocalLimiter) Allow(key string) bool

type RatePolicy

type RatePolicy struct {
	Limit  int
	Window time.Duration
}

type RedisLimiter

type RedisLimiter struct {
	// contains filtered or unexported fields
}

func NewRedisLimiter

func NewRedisLimiter(dsn string, policy RatePolicy) (*RedisLimiter, error)

func (*RedisLimiter) Allow

func (l *RedisLimiter) Allow(key string) bool

Jump to

Keyboard shortcuts

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