ratelimit

package
v3.1.19 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Max:        100,
	Window:     time.Minute,
	Algorithm:  FixedWindow,
	Prefix:     "core:ratelimit:",
	StatusCode: core.StatusTooManyRequests,
	Message:    "rate limit exceeded",
}

Functions

func New

func New(conf ...Config) core.HandlerFunc

func RedisNil

func RedisNil(err error) bool

RedisNil reports whether the backend error is redis.Nil.

Types

type Algorithm

type Algorithm string
const (
	FixedWindow   Algorithm = "fixed_window"
	SlidingWindow Algorithm = "sliding_window"
)

type Config

type Config struct {
	Max        int64
	Window     time.Duration
	Algorithm  Algorithm
	Prefix     string
	StatusCode int
	Message    string
	KeyFunc    func(c core.Ctx) string
	Redis      *core.RedisClient
}

type Limiter

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

func (*Limiter) Middleware

func (l *Limiter) Middleware() core.HandlerFunc

Jump to

Keyboard shortcuts

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