Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimitRoundTripper ¶
type RateLimitRoundTripper struct {
// contains filtered or unexported fields
}
RateLimitRoundTripper is an http.RoundTripper that rate limits requests.
func New ¶
func New(roudtripper http.RoundTripper, limiter *rate.Limiter, opts ...RateLimitRoundTripperOption) *RateLimitRoundTripper
New returns a a new RateLimitRoundtripper.
func (*RateLimitRoundTripper) RoundTrip ¶
RoundTrip implements http.RoundTripper.
It blocks, waiting until the rate limiter permits the request to be made, then delegates to the underlying RoundTripper to make the request. If the request's context is canceled or its deadline is exceeded while waiting, an error is returned.
type RateLimitRoundTripperOption ¶
type RateLimitRoundTripperOption func(*RateLimitRoundTripper)
func WithOnRespFunc ¶
func WithOnRespFunc(fn OnRespFunc) RateLimitRoundTripperOption
func WithRateLimitHeaderCheck ¶
func WithRateLimitHeaderCheck() RateLimitRoundTripperOption
WithRateLimitHeaderCheck returns a RateLimitRoundTripperOption that checks the response headers for rate limit information.
See: https://www.ietf.org/archive/id/draft-polli-ratelimit-headers-02.html
Click to show internal directories.
Click to hide internal directories.