Documentation ¶
Overview ¶
Package ratelimit implements rate limiting of HTTP requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidRate is used when the rate is less than 1 request per second. ErrInvalidRate = errors.New("invalid rate; needs to be between 1 and 3600 seconds") )
Functions ¶
func IPBucket ¶
IPBucket is a generator of rate limit buckets based on client's IP address. Optional filter function can be passed in, defaults to finding first public IP, see: https://godoc.org/github.com/ripexz/rip
Types ¶
type Config ¶
type Config struct { Pool redisPool GrantOnErr bool ErrorLog func(error, string) // GetKey generates bucket keys. GetKey func(*http.Request) string // Ignore rate limit verification for this request if this returns true. Ignore func(*http.Request) bool // Rates returns the number of API calls (to all endpoints) that can be made // by the client considering the request. If null global values will be used. Rates func(*http.Request) (perPeriod, periodSeconds int) }
Config for RateLimit
Click to show internal directories.
Click to hide internal directories.