Documentation
¶
Overview ¶
Package httputil provides shared HTTP utilities for API clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAPIError ¶
IsAPIError reports whether err (or anything it wraps) is an *APIError.
Types ¶
type APIError ¶
APIError is a typed error carrying an upstream HTTP status code along with a provider-specific, user-actionable hint. Clients construct one via Classify when an upstream returns a non-2xx response; callers can recover the status code and provider via errors.As.
type HTTPDoer ¶
HTTPDoer is the interface satisfied by *http.Client; use it in API client structs so tests can inject a mock without a real network.
type RateLimiter ¶
RateLimiter configures exponential backoff with jitter for rate-limited APIs.
func Default ¶
func Default() *RateLimiter
Default returns a RateLimiter with the standard configuration used across all API clients (2 s base, 30 s max, 5 retries).
func (*RateLimiter) Backoff ¶
func (r *RateLimiter) Backoff(attempt int, retryAfter string) time.Duration
Backoff returns the delay before the next retry attempt. If the Retry-After response header is a valid integer, that value is used directly. Otherwise exponential backoff with ±30 % jitter is applied, capped at MaxDelay.