Documentation ¶
Index ¶
- func KeyByEndpoint(r *http.Request) (string, error)
- func KeyByIP(r *http.Request) (string, error)
- func KeyByRealIP(r *http.Request) (string, error)
- func Limit(requestLimit int, windowLength time.Duration, options ...Option) func(next http.Handler) http.Handler
- func LimitAll(requestLimit int, windowLength time.Duration) func(next http.Handler) http.Handler
- func LimitByIP(requestLimit int, windowLength time.Duration) func(next http.Handler) http.Handler
- func LimitByRealIP(requestLimit int, windowLength time.Duration) func(next http.Handler) http.Handler
- func LimitCounterKey(key string, window time.Time) uint64
- func NewRateLimiter(requestLimit int, windowLength time.Duration, options ...Option) *rateLimiter
- func WithIncrement(ctx context.Context, value int) context.Context
- func WithRequestLimit(ctx context.Context, value int) context.Context
- type KeyFunc
- type LimitCounter
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LimitByRealIP ¶ added in v0.6.0
func NewRateLimiter ¶
func WithIncrement ¶ added in v0.8.0
Types ¶
type LimitCounter ¶
type Option ¶
type Option func(rl *rateLimiter)
func WithKeyByIP ¶ added in v0.7.0
func WithKeyByIP() Option
func WithKeyByRealIP ¶ added in v0.7.0
func WithKeyByRealIP() Option
func WithKeyFuncs ¶
func WithLimitCounter ¶
func WithLimitCounter(c LimitCounter) Option
func WithLimitHandler ¶
func WithLimitHandler(h http.HandlerFunc) Option
Click to show internal directories.
Click to hide internal directories.