Documentation ¶
Overview ¶
Ratelimit implementation
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultIdentifier ¶
func SetupState ¶
func SetupState(s *RLState)
Types ¶
type Limit ¶
type Limit struct { // Exceeded is true if the ratelimit has been exceeded Exceeded bool // Made is the number of requests made in the ratelimit Made int // Remaining is the number of requests remaining in the ratelimit Remaining int // TimeToReset is the time remaining until the ratelimit resets TimeToReset time.Duration // GotIdentifier is the identifier of the ratelimit GotIdentifier string // MaxRequests is the maximum number of requests allowed in the interval specified by Expiry for the bucket MaxRequests int // Bucket is the bucket to use for the ratelimit Bucket string }
Limit is used to check if the ratelimit has been exceeded
type Ratelimit ¶
type Ratelimit struct { // Expiry is the time for the ratelimit to expire Expiry time.Duration // MaxRequests is the maximum number of requests allowed in the interval specified by Expiry for the bucket MaxRequests int // Bucket is the bucket to use for the ratelimit Bucket string // Identifier is the identifier of the ratelimit, otherwise DefaultIdentifier is used Identifier func(r *http.Request) string }
Click to show internal directories.
Click to hide internal directories.