Versions in this module Expand all Collapse all v0 v0.8.1 Aug 14, 2026 v0.8.0 Aug 14, 2026 Changes in this version + func Stream[TRequest any](client *Client, method HTTPMethod, path string, request TRequest, ...) (*http.Response, error) type ClientOptions + Circuit circuit.CircuitBreaker type ErrorType + const ErrorTypeCircuit v0.7.0 Dec 29, 2025 v0.6.0 Dec 22, 2025 v0.5.0 Dec 22, 2025 v0.4.0 Dec 22, 2025 v0.3.0 Dec 22, 2025 v0.2.0 Dec 22, 2025 Changes in this version + func AddAutoMetrics() (RequestHook, ResponseHook, func() MetricsSnapshot) + func GenerateDedupeKey(req *http.Request) string + func GetRequestID(c context.Context) (string, bool) + func RequestIDFromRequest(req *http.Request) (string, bool) + func RequestIDFromResponse(resp *http.Response) (string, bool) + func WithRequestID(c context.Context, requestID string) context.Context + type AuthConfig struct + HeaderName string + HeaderValue string + Password string + Token string + Type AuthType + Username string + type AuthProvider interface + GetAuthHeader func(token string) string + GetToken func(ctx context.Context) (string, error) + type AuthType int + const AuthTypeAPIKey + const AuthTypeBasic + const AuthTypeBearer + const AuthTypeCustom + type BodyProvider interface + Body func() (io.Reader, error) + ContentType func() string + type Cache interface + Clear func() + Delete func(key string) + Get func(key string) (*CacheEntry, bool) + Set func(key string, entry CacheEntry) + type CacheEntry struct + Data []byte + Headers http.Header + StatusCode int + TTL time.Duration + Timestamp time.Time + type Client struct + Config ClientOptions + Metrics *MetricsCollector + func NewClient(options ClientOptions) *Client + func (c *Client) Delete(path string, opts ...*RequestOptions) (*Response[any], error) + func (c *Client) Do(method HTTPMethod, path string, opts ...*RequestOptions) (*Response[any], error) + func (c *Client) Get(path string, opts ...*RequestOptions) (*Response[any], error) + func (c *Client) GetMetrics() MetricsSnapshot + func (c *Client) Head(path string, opts ...*RequestOptions) (*Response[any], error) + func (c *Client) Options(path string, opts ...*RequestOptions) (*Response[any], error) + func (c *Client) Patch(path string, opts ...*RequestOptions) (*Response[any], error) + func (c *Client) Post(path string, opts ...*RequestOptions) (*Response[any], error) + func (c *Client) Put(path string, opts ...*RequestOptions) (*Response[any], error) + func (c *Client) Shutdown(timeout time.Duration) error + type ClientError struct + Attempt int + Cause error + Message string + Method string + Route string + StatusCode int + Timestamp time.Time + Type ErrorType + URL string + func (e ClientError) Error() string + func (e ClientError) Unwrap() error + func (e ClientError) WithContext(req *http.Request, attempt int) ClientError + type ClientOptions struct + AdaptiveTimeout bool + AutoHandleRateLimit bool + BaseURL string + Deduplicator *Deduplicator + HTTPClient *http.Client + Headers http.Header + MaxRetries int + RateLimitUpdater RateLimitUpdater + RateLimiter RateLimiter + RequestHooks []RequestHook + ResponseHooks []ResponseHook + RetryDelay time.Duration + RetryMultiplier float64 + Timeout time.Duration + UserAgent string + type CompressionConfig struct + ContentTypes []string + Level int + MinSize int + Type CompressionType + func DefaultCompressionConfig() CompressionConfig + type CompressionType int + const CompressionTypeBrotli + const CompressionTypeDeflate + const CompressionTypeGzip + type DedupeConfig struct + Enabled bool + KeyGenerator func(req *http.Request) string + MaxSize int + WindowSize time.Duration + func DefaultDedupeConfig() DedupeConfig + type DedupeStats struct + Deduped int64 + Inflight int64 + type Deduplicator struct + func NewDeduplicator(config DedupeConfig) *Deduplicator + func (d *Deduplicator) Dedupe(ctx context.Context, key string, fn func() (*http.Response, error)) (*http.Response, error) + func (d *Deduplicator) Stats() DedupeStats + type Deserializable interface + UnmarshalJSON func(data []byte) error + type EmptyRequest struct + type EmptyResponse struct + type ErrorType int + const ErrorTypeAuth + const ErrorTypeNetwork + const ErrorTypeRateLimit + const ErrorTypeRequest + const ErrorTypeResponse + const ErrorTypeTimeout + type HTTPMethod string + const MethodDELETE + const MethodGET + const MethodHEAD + const MethodOPTIONS + const MethodPATCH + const MethodPOST + const MethodPUT + type HeaderConfig struct + AddHeaders map[string]string + CustomHeaders map[string]string + RemoveHeaders []string + UserAgent string + func DefaultHeaderConfig() HeaderConfig + type HookChain struct + func NewHookChain() *HookChain + func (hc *HookChain) AddRequestHook(hook RequestHook) *HookChain + func (hc *HookChain) AddResponseHook(hook ResponseHook) *HookChain + func (hc *HookChain) ApplyRequestHooks(req *http.Request) error + func (hc *HookChain) ApplyResponseHooks(resp *http.Response) error + type InMemoryCache struct + func NewInMemoryCache() *InMemoryCache + func (c *InMemoryCache) Clear() + func (c *InMemoryCache) Delete(key string) + func (c *InMemoryCache) Get(key string) (*CacheEntry, bool) + func (c *InMemoryCache) Set(key string, entry CacheEntry) + type JSONValidator struct + func (v *JSONValidator) Validate(data []byte, contentType string) error + type LogLevel int + const LogLevelDebug + const LogLevelError + const LogLevelInfo + const LogLevelWarn + type LoggingConfig struct + IncludeBody bool + Level LogLevel + Logger *log.Logger + MaxBodySize int + func DefaultLoggingConfig() LoggingConfig + type MetricsCollector struct + ErrorCount atomic.Int64 + MaxDuration atomic.Int64 + MinDuration atomic.Int64 + RequestCount atomic.Int64 + ResponseCount atomic.Int64 + StartTime time.Time + StatusCodeCounts map[int]*atomic.Int64 + TotalDuration atomic.Int64 + func NewMetricsCollector() *MetricsCollector + func (m *MetricsCollector) GetMetrics() MetricsSnapshot + func (m *MetricsCollector) RecordRequest() + func (m *MetricsCollector) RecordResponse(statusCode int, duration time.Duration) + type MetricsSnapshot struct + AverageDuration time.Duration + ErrorCount int64 + MaxDuration time.Duration + MinDuration time.Duration + RequestCount int64 + ResponseCount int64 + StatusCodeCounts map[int]int64 + Uptime time.Duration + func (m *MetricsSnapshot) ErrorRate() float64 + func (m *MetricsSnapshot) RequestsPerSecond() float64 + type NoopRateLimitUpdater struct + func (n *NoopRateLimitUpdater) UpdateFromHeaders(method, endpoint string, info *RateLimitInfo) error + type NoopRateLimiter struct + func (n *NoopRateLimiter) Allow(ctx context.Context, method, endpoint string) bool + func (n *NoopRateLimiter) Wait(ctx context.Context, method, endpoint string) error + type RateLimitHandler interface + type RateLimitInfo struct + Bucket string + Global bool + Limit int + Remaining int + Reset time.Time + ResetAfter time.Duration + RetryAfter time.Duration + Scope string + func ParseRateLimitHeaders(headers http.Header) *RateLimitInfo + func (r *RateLimitInfo) IsExhausted() bool + func (r *RateLimitInfo) WaitDuration() time.Duration + type RateLimitUpdater interface + UpdateFromHeaders func(method, endpoint string, info *RateLimitInfo) error + type RateLimiter interface + Allow func(ctx context.Context, method, endpoint string) bool + Wait func(ctx context.Context, method, endpoint string) error + type RequestHook func(req *http.Request) error + func AddAPIKeyAuth(apiKey, headerName string) RequestHook + func AddAPIKeyHeaderAuth(apiKey string) RequestHook + func AddAccept(accept string) RequestHook + func AddAuth(config AuthConfig) RequestHook + func AddAuthHeader(header, value string) RequestHook + func AddAuthentication(authProvider AuthProvider) RequestHook + func AddAutoCompression() RequestHook + func AddBasicAuth(username, password string) RequestHook + func AddBearerAuth(token string) RequestHook + func AddCompression(config CompressionConfig) RequestHook + func AddCompressionLevel(level int) RequestHook + func AddContentType(contentType string) RequestHook + func AddCorrelationID(config RequestIDConfig) RequestHook + func AddDebugLogging(config LoggingConfig) RequestHook + func AddHeader(config HeaderConfig) RequestHook + func AddHeaderSet(key, value string) RequestHook + func AddLogging(config LoggingConfig) RequestHook + func AddMetrics(collector *MetricsCollector) RequestHook + func AddNoCache() RequestHook + func AddRequestID(config RequestIDConfig) RequestHook + func AddSecurityHeaders() RequestHook + func AddStructuredLogging(config LoggingConfig) RequestHook + func AddTracing(config RequestIDConfig) RequestHook + func AddUserAgent(userAgent string) RequestHook + func AddValidation(validator Validator) RequestHook + type RequestIDConfig struct + ContextKey any + Generator RequestIDGenerator + HeaderName string + Propagate bool + func DefaultRequestIDConfig() RequestIDConfig + type RequestIDGenerator interface + Generate func() string + type RequestMetrics struct + AverageResponseTime time.Duration + FailedRequests int64 + SuccessfulRequests int64 + TotalRequests int64 + type RequestOptions struct + Body any + Context context.Context + DisableDedupe bool + Headers http.Header + IdempotencyKey string + Query map[string]any + RequestHooks []RequestHook + ResponseHooks []ResponseHook + Retries *int + Timeout *time.Duration + type Response struct + Data T + Headers http.Header + Raw *http.Response + StatusCode int + func DoWithType[T any](client *Client, method HTTPMethod, path string, opts ...*RequestOptions) (*Response[T], error) + func Execute[TRequest any, TResponse any](client *Client, route Route[TRequest, TResponse], request TRequest, ...) (*Response[TResponse], error) + func (r *Response[T]) Bytes() ([]byte, error) + func (r *Response[T]) IsClientError() bool + func (r *Response[T]) IsError() bool + func (r *Response[T]) IsServerError() bool + func (r *Response[T]) IsSuccess() bool + func (r *Response[T]) JSON(target any) error + func (r *Response[T]) String() (string, error) + type ResponseHook func(resp *http.Response) error + func AddRateLimitHandler(updater RateLimitUpdater) ResponseHook + func AddRateLimitLogging(logFn func(method, path string, info *RateLimitInfo)) ResponseHook + func AddRateLimitRetry() ResponseHook + func AddResponseCache(cache Cache) ResponseHook + func AddResponseCompression(config CompressionConfig) ResponseHook + func AddResponseDebug(config LoggingConfig) ResponseHook + func AddResponseDecompression() ResponseHook + func AddResponseErrorLogging(config LoggingConfig) ResponseHook + func AddResponseLogging(config LoggingConfig) ResponseHook + func AddResponseMetrics(collector *MetricsCollector) ResponseHook + func AddResponseRequestID(config RequestIDConfig) ResponseHook + func AddResponseStructured(config LoggingConfig) ResponseHook + func AddResponseTimeout(timeout time.Duration) ResponseHook + type Route struct + Method HTTPMethod + Path string + func NewRoute[TRequest, TResponse any](method HTTPMethod, path string) Route[TRequest, TResponse] + type SequentialGenerator struct + func (g *SequentialGenerator) Generate() string + type Serializable interface + MarshalJSON func() ([]byte, error) + type StaticAuthProvider struct + Prefix string + Token string + func (a *StaticAuthProvider) GetAuthHeader(token string) string + func (a *StaticAuthProvider) GetToken(ctx context.Context) (string, error) + type TimestampGenerator struct + func (g *TimestampGenerator) Generate() string + type UUIDGenerator struct + func (g *UUIDGenerator) Generate() string + type Validator interface + Validate func(data []byte, contentType string) error