Versions in this module Expand all Collapse all v0 v0.1.0 Jan 5, 2026 Changes in this version + func Key(key string) func(ctx context.Context, r *app.RequestContext) (string, error) + func KeyByEndpoint(_ context.Context, r *app.RequestContext) (string, error) + func KeyByFullPath(_ context.Context, r *app.RequestContext) (string, error) + func KeyByIP(_ context.Context, r *app.RequestContext) (string, error) + func Middleware(l *RateLimiter) app.HandlerFunc + func WithIncrement(ctx context.Context, value int) context.Context + func WithRequestLimit(ctx context.Context, value int) context.Context + type KeyFunc func(ctx context.Context, r *app.RequestContext) (string, error) + type LimitCounter interface + Config func(requestLimit int, windowLength time.Duration) + Get func(key string, currentWindow, previousWindow time.Time) (int, int, error) + Increment func(key string, currentWindow time.Time) error + IncrementBy func(key string, currentWindow time.Time, amount int) error + type Option func(rl *RateLimiter) + func WithErrorHandler(h func(ctx context.Context, c *app.RequestContext, err error)) Option + func WithKeyByEndpoint() Option + func WithKeyByFullPath() Option + func WithKeyByIP() Option + func WithKeyFuncs(keyFuncs ...KeyFunc) Option + func WithLimitCounter(c LimitCounter) Option + func WithLimitHandler(h app.HandlerFunc) Option + func WithNoop() Option + func WithResponseHeaders(headers ResponseHeaders) Option + type RateLimiter struct + func NewRateLimiter(requestLimit int, windowLength time.Duration, options ...Option) *RateLimiter + func (l *RateLimiter) Counter() LimitCounter + func (l *RateLimiter) OnLimit(ctx context.Context, r *app.RequestContext, key string) bool + func (l *RateLimiter) RespondOnLimit(ctx context.Context, r *app.RequestContext, key string) bool + func (l *RateLimiter) Status(key string) (bool, float64, error) + type ResponseHeaders struct + Increment string + Limit string + Remaining string + Reset string + RetryAfter string