Documentation
¶
Index ¶
- func Limit(maxTokens, refillRate, tokensPerRefill int, config Config) func(next http.Handler) http.Handler
- func LimitByIp(maxTokens, refillRate, tokensPerRefill int, config Config) func(next http.Handler) http.Handler
- func LimitIpByEndpoint(maxTokens, refillRate, tokensPerRefill int, config Config) func(next http.Handler) http.Handler
- func MatchPathPattern(pattern, path string) bool
- func WithConfig(config Config) func(next http.Handler) http.Handler
- type ClientRequestData
- type Config
- type TokenBucket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LimitIpByEndpoint ¶
func MatchPathPattern ¶
Types ¶
type ClientRequestData ¶
type Config ¶
type Config struct {
IgnorePaths []string `json:"ignorePaths" yaml:"ignorePaths"`
MaxTokens int `json:"maxTokens" yaml:"maxTokens"`
RefillRate int `json:"refillRate" yaml:"refillRate"`
TokensPerRefill int `json:"tokensPerRefill" yaml:"tokensPerRefill"`
LimitMethod func(maxTokens, refillRate, tokensPerRefill int, config Config) func(next http.Handler) http.Handler
}
type TokenBucket ¶
type TokenBucket struct {
// contains filtered or unexported fields
}
func NewTokenBucket ¶
func NewTokenBucket(maxTokens, refillRate int, tokensPerRefill int, config Config) *TokenBucket
func (*TokenBucket) SetClientForTest ¶
func (tb *TokenBucket) SetClientForTest(ip string, tokens int, lastRequest time.Time)
Click to show internal directories.
Click to hide internal directories.