Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimitMiddleware ¶
type RateLimitMiddleware struct {
// contains filtered or unexported fields
}
RateLimitMiddleware is a http middleware for applying rate limit to an API. If the limit is exceeded, a status code 429 is returned. If an error is encountered while checking the limit, a status code 500 is returned. It also set the headers with rate limit information such as limit, retry after, and reset after. Ref: https://tools.ietf.org/id/draft-polli-ratelimit-headers-00.html
func NewRateLimiterMiddleware ¶
func NewRateLimiterMiddleware(limiter ratelimiter.RateLimiter, clock clock.Clock) *RateLimitMiddleware
NewRateLimiterMiddleware instantiates a new rate limiter middleware
func (*RateLimitMiddleware) AttachRateLimitMiddleware ¶
func (m *RateLimitMiddleware) AttachRateLimitMiddleware(next http.Handler) http.Handler
AttachRateLimitMiddleware wraps the passed http handler with a rate limiter middleware. The passed handler is only called if the rate limit threshold has not exceeded yet.
Click to show internal directories.
Click to hide internal directories.