Documentation ¶
Index ¶
- Constants
- func ExponentialBackoffWaitFor(defaultWait time.Duration, retry int) time.Duration
- func GetName(r *http.Request) (name string, ok bool)
- func GetQuery(r *http.Request) (name string, ok bool)
- func GetWarning(r *http.Request) (warning string, ok bool)
- func HeaderString(h http.Header) string
- func IsRateLimited(resp *http.Response, body []byte) bool
- func IsRateLimitedBody(resp *http.Response, body []byte) bool
- func IsRateLimitedResponse(resp *http.Response) bool
- func NewUserAgentTransport(userAgent string, base http.RoundTripper) http.RoundTripper
- func RateLimitedRetryFor(resp *http.Response, defaultWait time.Duration, retry int) time.Duration
- func SetName(r *http.Request, name string) *http.Request
- func SetQuery(r *http.Request, query string) *http.Request
- func SetWarning(r *http.Request, warning string) *http.Request
- type QueryParams
Constants ¶
const ( ContextWarning string = "Warning" ContextName string = "Name" ContextQuery string = "Query" )
Variables ¶
This section is empty.
Functions ¶
func ExponentialBackoffWaitFor ¶
ExpontentialBackoffWatiFor accepts a default wait duration and the current retry count and returns a new duration
func GetWarning ¶
GetWarning Extracts a warning message from the request context if it exists
func HeaderString ¶
HeaderString writes the request/response http.Header to a string.
func IsRateLimited ¶
IsRateLimited accepts a response and body to determine if either indicate a rate limited return
func IsRateLimitedBody ¶
IsRateLimitedBody attempts to determine if a response body indicates throttling has occurred. This function is a result of some API providers (AWS) returning a 400 status code instead of 429 for rate limit exceptions.
func IsRateLimitedResponse ¶
IsRateLimitedResponse returns true if the status code is a 429 (TooManyRequests)
func NewUserAgentTransport ¶
func NewUserAgentTransport(userAgent string, base http.RoundTripper) http.RoundTripper
NewUserAgentTransport creates a RoundTripper that attaches the configured user agent.
func RateLimitedRetryFor ¶
RateLimitedRetryFor returns the parsed Retry-After header relative to the current time. If the Retry-After header does not exist, the defaultWait parameter is returned.
func SetName ¶
SetName Sets the name value on the provided request and returns a new instance of the request with the new context.
Types ¶
type QueryParams ¶
type QueryParams interface { mapper.PrimitiveMap // InvalidKeys returns the set of param keys which are not present in the // possible valid set. It is a set subtraction: present - valid = invalid // // Example usage to catch a typo: // qp.InvalidKeys([]string{"window", "aggregate", "filterClusters"}) -> // "filterClsuters" // // If qp contains no keys, then this should always return an empty slice/nil InvalidKeys(possibleValidKeys []string) (invalidKeys []string) }
QueryParams provides basic map access to URL values as well as providing helpful additional functionality for validation.
func NewQueryParams ¶
func NewQueryParams(values url.Values) QueryParams
NewQueryParams creates a primitive map using the request query parameters