Documentation
¶
Index ¶
- 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 Stream[TRequest any](client *Client, method HTTPMethod, path string, request TRequest, ...) (*http.Response, error)
- func WithRequestID(c context.Context, requestID string) context.Context
- type AuthConfig
- type AuthProvider
- type AuthType
- type BodyProvider
- type Cache
- type CacheEntry
- type 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
- type ClientOptions
- type CompressionConfig
- type CompressionType
- type DedupeConfig
- type DedupeStats
- type Deduplicator
- type Deserializable
- type EmptyRequest
- type EmptyResponse
- type ErrorType
- type HTTPMethod
- type HeaderConfig
- type HookChain
- type InMemoryCache
- type JSONValidator
- type LogLevel
- type LoggingConfig
- type MetricsCollector
- type MetricsSnapshot
- type NoopRateLimitUpdater
- type NoopRateLimiter
- type RateLimitHandler
- type RateLimitInfo
- type RateLimitUpdater
- type RateLimiter
- type RequestHook
- 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
- type RequestIDGenerator
- type RequestMetrics
- type RequestOptions
- type Response
- type ResponseHook
- 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
- type SequentialGenerator
- type Serializable
- type StaticAuthProvider
- type TimestampGenerator
- type UUIDGenerator
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAutoMetrics ¶
func AddAutoMetrics() (RequestHook, ResponseHook, func() MetricsSnapshot)
AddAutoMetrics creates a simple metrics middleware that doesn't require a collector
func GenerateDedupeKey ¶
GenerateDedupeKey creates a default deduplication key from a request
func GetRequestID ¶
GetRequestID extracts the request ID from context
func RequestIDFromRequest ¶
RequestIDFromRequest extracts the request ID from an HTTP request
func RequestIDFromResponse ¶
RequestIDFromResponse extracts the request ID from an HTTP response
func Stream ¶ added in v0.8.0
func Stream[TRequest any](client *Client, method HTTPMethod, path string, request TRequest, options *RequestOptions) (*http.Response, error)
Stream sends an HTTP request and returns the raw response with Body still open. The caller must Close the body.
Unlike Execute, Stream never retries after headers or a body exist — including 5xx. Closing and re-POSTing an LLM stream can duplicate tool calls. Transport errors that occur before any response are retried according to MaxRetries / RequestOptions.Retries.
Stream does not apply AdaptiveTimeout. LLM callers should set http.Client.Timeout (around 10 minutes) or a request context deadline.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Type AuthType
Token string
Username string
Password string
HeaderName string
HeaderValue string
}
AuthConfig configures authentication hooks
type AuthProvider ¶
type AuthProvider interface {
GetToken(ctx context.Context) (string, error)
GetAuthHeader(token string) string
}
AuthProvider interface for authentication
type BodyProvider ¶
BodyProvider allows custom body serialization
type Cache ¶
type Cache interface {
Get(key string) (*CacheEntry, bool)
Set(key string, entry CacheEntry)
Delete(key string)
Clear()
}
Cache interface for caching hooks
type CacheEntry ¶
type CacheEntry struct {
Data []byte
Headers http.Header
StatusCode int
Timestamp time.Time
TTL time.Duration
}
CacheEntry represents a cached response
type Client ¶
type Client struct {
Config ClientOptions
// Metrics tracking
Metrics *MetricsCollector
// contains filtered or unexported fields
}
Client is a type-safe HTTP client with retries and optional rate limiting. Set ClientOptions.Circuit to wrap HTTPClient.Do in an Ion circuit breaker.
func NewClient ¶
func NewClient(options ClientOptions) *Client
NewClient creates a new type-safe HTTP client
func (*Client) Do ¶
func (c *Client) Do(method HTTPMethod, path string, opts ...*RequestOptions) (*Response[any], error)
Do executes an HTTP request with the specified method and returns the response
func (*Client) GetMetrics ¶
func (c *Client) GetMetrics() MetricsSnapshot
GetMetrics returns current client metrics
type ClientError ¶
type ClientError struct {
Type ErrorType
Message string
StatusCode int
Route string
Method string // HTTP method
URL string // Full URL
Attempt int // Retry attempt number
Timestamp time.Time // When error occurred
Cause error
}
Error types for type-safe error handling
func (ClientError) Error ¶
func (e ClientError) Error() string
func (ClientError) Unwrap ¶
func (e ClientError) Unwrap() error
func (ClientError) WithContext ¶
func (e ClientError) WithContext(req *http.Request, attempt int) ClientError
WithContext adds request context information to the error
type ClientOptions ¶
type ClientOptions struct {
// Base configuration
BaseURL string
UserAgent string
Headers http.Header
Timeout time.Duration
// Request handling
MaxRetries int
RetryDelay time.Duration
RetryMultiplier float64
// Hooks
RequestHooks []RequestHook
ResponseHooks []ResponseHook
// HTTP client
HTTPClient *http.Client
// Circuit, if set, wraps HTTPClient.Do in circuit.Execute.
// An open circuit fails fast as ClientError with Type ErrorTypeCircuit.
Circuit circuit.CircuitBreaker
// Resilience configuration
AdaptiveTimeout bool
// Rate limiting
RateLimiter RateLimiter
RateLimitUpdater RateLimitUpdater
AutoHandleRateLimit bool
// Deduplication
Deduplicator *Deduplicator
}
ClientOptions configures the HTTP client behavior
type CompressionConfig ¶
type CompressionConfig struct {
Type CompressionType
Level int
MinSize int
ContentTypes []string
}
CompressionConfig configures compression middleware
func DefaultCompressionConfig ¶
func DefaultCompressionConfig() CompressionConfig
DefaultCompressionConfig returns a default compression configuration
type CompressionType ¶
type CompressionType int
CompressionType represents the type of compression
const ( CompressionTypeGzip CompressionType = iota CompressionTypeDeflate CompressionTypeBrotli )
type DedupeConfig ¶
type DedupeConfig struct {
// Enabled enables request deduplication
Enabled bool
// WindowSize is the time window for deduplication
// Requests with the same key within this window will be deduplicated
WindowSize time.Duration
// MaxSize is the maximum number of entries in the dedupe cache
MaxSize int
// KeyGenerator generates a unique key for a request
// If nil, defaults to method + URL
KeyGenerator func(req *http.Request) string
}
DedupeConfig configures request deduplication behavior
func DefaultDedupeConfig ¶
func DefaultDedupeConfig() DedupeConfig
DefaultDedupeConfig returns sensible defaults for deduplication
type DedupeStats ¶
type DedupeStats struct {
// Deduped is the number of requests that were deduplicated
Deduped int64
// Inflight is the current number of in-flight requests
Inflight int64
}
DedupeStats contains deduplication statistics
type Deduplicator ¶
type Deduplicator struct {
// contains filtered or unexported fields
}
Deduplicator prevents duplicate concurrent requests
func NewDeduplicator ¶
func NewDeduplicator(config DedupeConfig) *Deduplicator
NewDeduplicator creates a new request deduplicator
func (*Deduplicator) Dedupe ¶
func (d *Deduplicator) Dedupe(ctx context.Context, key string, fn func() (*http.Response, error)) (*http.Response, error)
Dedupe executes a request with deduplication If a request with the same key is already in flight, wait for its result
func (*Deduplicator) Stats ¶
func (d *Deduplicator) Stats() DedupeStats
Stats returns deduplication statistics
type Deserializable ¶
Deserializable represents types that can be deserialized from responses
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod represents supported HTTP methods
const ( MethodGET HTTPMethod = "GET" MethodPOST HTTPMethod = "POST" MethodPUT HTTPMethod = "PUT" MethodPATCH HTTPMethod = "PATCH" MethodDELETE HTTPMethod = "DELETE" MethodHEAD HTTPMethod = "HEAD" MethodOPTIONS HTTPMethod = "OPTIONS" )
type HeaderConfig ¶
type HeaderConfig struct {
UserAgent string
CustomHeaders map[string]string
RemoveHeaders []string
AddHeaders map[string]string
}
HeaderConfig configures header hooks
func DefaultHeaderConfig ¶
func DefaultHeaderConfig() HeaderConfig
DefaultHeaderConfig returns a default header configuration
type HookChain ¶
type HookChain struct {
// contains filtered or unexported fields
}
HookChain manages a chain of hook functions This is an optional utility for advanced use cases; most users will use slices directly
func (*HookChain) AddRequestHook ¶
func (hc *HookChain) AddRequestHook(hook RequestHook) *HookChain
AddRequestHook adds a request hook to the chain
func (*HookChain) AddResponseHook ¶
func (hc *HookChain) AddResponseHook(hook ResponseHook) *HookChain
AddResponseHook adds a response hook to the chain
func (*HookChain) ApplyRequestHooks ¶
ApplyRequestHooks applies all request hooks in order
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
InMemoryCache provides a simple in-memory cache implementation
func NewInMemoryCache ¶
func NewInMemoryCache() *InMemoryCache
NewInMemoryCache creates a new in-memory cache
func (*InMemoryCache) Clear ¶
func (c *InMemoryCache) Clear()
func (*InMemoryCache) Delete ¶
func (c *InMemoryCache) Delete(key string)
func (*InMemoryCache) Get ¶
func (c *InMemoryCache) Get(key string) (*CacheEntry, bool)
func (*InMemoryCache) Set ¶
func (c *InMemoryCache) Set(key string, entry CacheEntry)
type LoggingConfig ¶
LoggingConfig configures the logging hooks
func DefaultLoggingConfig ¶
func DefaultLoggingConfig() LoggingConfig
DefaultLoggingConfig returns a default logging configuration
type MetricsCollector ¶
type MetricsCollector struct {
// Request metrics
RequestCount atomic.Int64
ResponseCount atomic.Int64
ErrorCount atomic.Int64
// Duration metrics
TotalDuration atomic.Int64 // nanoseconds
MinDuration atomic.Int64 // nanoseconds
MaxDuration atomic.Int64 // nanoseconds
// Status code metrics
StatusCodeCounts map[int]*atomic.Int64
// Start time for uptime calculation
StartTime time.Time
// contains filtered or unexported fields
}
MetricsCollector collects and stores metrics
func NewMetricsCollector ¶
func NewMetricsCollector() *MetricsCollector
NewMetricsCollector creates a new metrics collector
func (*MetricsCollector) GetMetrics ¶
func (m *MetricsCollector) GetMetrics() MetricsSnapshot
GetMetrics returns current metrics
func (*MetricsCollector) RecordRequest ¶
func (m *MetricsCollector) RecordRequest()
RecordRequest records a request metric
func (*MetricsCollector) RecordResponse ¶
func (m *MetricsCollector) RecordResponse(statusCode int, duration time.Duration)
RecordResponse records a response metric
type MetricsSnapshot ¶
type MetricsSnapshot struct {
RequestCount int64
ResponseCount int64
ErrorCount int64
AverageDuration time.Duration
MinDuration time.Duration
MaxDuration time.Duration
StatusCodeCounts map[int]int64
Uptime time.Duration
}
MetricsSnapshot represents a snapshot of metrics at a point in time
func (*MetricsSnapshot) ErrorRate ¶
func (m *MetricsSnapshot) ErrorRate() float64
ErrorRate returns the error rate as a percentage
func (*MetricsSnapshot) RequestsPerSecond ¶
func (m *MetricsSnapshot) RequestsPerSecond() float64
RequestsPerSecond returns the average requests per second
type NoopRateLimitUpdater ¶
type NoopRateLimitUpdater struct{}
NoopRateLimitUpdater is an updater that does nothing
func (*NoopRateLimitUpdater) UpdateFromHeaders ¶
func (n *NoopRateLimitUpdater) UpdateFromHeaders(method, endpoint string, info *RateLimitInfo) error
UpdateFromHeaders does nothing
type NoopRateLimiter ¶
type NoopRateLimiter struct{}
NoopRateLimiter is a rate limiter that allows all requests
type RateLimitHandler ¶
type RateLimitHandler interface {
RateLimiter
RateLimitUpdater
}
RateLimitHandler combines limiter and updater for full integration
type RateLimitInfo ¶
type RateLimitInfo struct {
// Limit is the maximum number of requests allowed in the current window
Limit int
// Remaining is the number of requests remaining in the current window
Remaining int
// Reset is the absolute time when the rate limit resets
Reset time.Time
// ResetAfter is the duration until the rate limit resets
ResetAfter time.Duration
// Bucket is the rate limit bucket identifier (Discord-style)
Bucket string
// Global indicates if this is a global rate limit
Global bool
// RetryAfter is the duration to wait before retrying (from Retry-After header)
RetryAfter time.Duration
// Scope indicates the rate limit scope (user, global, shared)
Scope string
}
RateLimitInfo contains parsed rate limit information from response headers
func ParseRateLimitHeaders ¶
func ParseRateLimitHeaders(headers http.Header) *RateLimitInfo
ParseRateLimitHeaders extracts rate limit info from HTTP response headers Supports standard rate limit headers and Discord-style bucket headers
func (*RateLimitInfo) IsExhausted ¶
func (r *RateLimitInfo) IsExhausted() bool
IsExhausted returns true if the rate limit has been exhausted
func (*RateLimitInfo) WaitDuration ¶
func (r *RateLimitInfo) WaitDuration() time.Duration
WaitDuration returns how long to wait before the next request
type RateLimitUpdater ¶
type RateLimitUpdater interface {
// UpdateFromHeaders updates rate limit state from response headers
UpdateFromHeaders(method, endpoint string, info *RateLimitInfo) error
}
RateLimitUpdater receives rate limit info from response headers
type RateLimiter ¶
type RateLimiter interface {
// Allow checks if a request is allowed without blocking
// Returns true if the request can proceed immediately
Allow(ctx context.Context, method, endpoint string) bool
// Wait blocks until the request is allowed or context is cancelled
Wait(ctx context.Context, method, endpoint string) error
}
RateLimiter is the interface for rate limiting requests
type RequestHook ¶
RequestHook processes requests before they are sent
func AddAPIKeyAuth ¶
func AddAPIKeyAuth(apiKey, headerName string) RequestHook
AddAPIKeyAuth creates an API key authentication hook
func AddAPIKeyHeaderAuth ¶
func AddAPIKeyHeaderAuth(apiKey string) RequestHook
AddAPIKeyHeaderAuth creates an API key authentication middleware with common header names
func AddAccept ¶
func AddAccept(accept string) RequestHook
AddAccept creates an accept header middleware
func AddAuth ¶
func AddAuth(config AuthConfig) RequestHook
AddAuth creates an authentication hook based on configuration
func AddAuthHeader ¶
func AddAuthHeader(header, value string) RequestHook
AddAuthHeader creates a generic header-based authentication hook
func AddAuthentication ¶
func AddAuthentication(authProvider AuthProvider) RequestHook
AddAuthentication adds authentication headers using an AuthProvider
func AddAutoCompression ¶
func AddAutoCompression() RequestHook
AddAutoCompression creates an automatic compression middleware
func AddBasicAuth ¶
func AddBasicAuth(username, password string) RequestHook
AddBasicAuth creates a Basic authentication hook
func AddBearerAuth ¶
func AddBearerAuth(token string) RequestHook
AddBearerAuth creates a Bearer token authentication hook
func AddCompression ¶
func AddCompression(config CompressionConfig) RequestHook
AddCompression creates a request compression middleware
func AddCompressionLevel ¶
func AddCompressionLevel(level int) RequestHook
AddCompressionLevel creates a compression level middleware
func AddContentType ¶
func AddContentType(contentType string) RequestHook
AddContentType creates a content type middleware
func AddCorrelationID ¶
func AddCorrelationID(config RequestIDConfig) RequestHook
AddCorrelationID creates a correlation ID middleware for distributed tracing
func AddDebugLogging ¶
func AddDebugLogging(config LoggingConfig) RequestHook
AddDebugLogging creates a debug logging middleware with detailed information
func AddHeader ¶
func AddHeader(config HeaderConfig) RequestHook
AddHeader creates a header hook based on configuration
func AddHeaderSet ¶
func AddHeaderSet(key, value string) RequestHook
AddHeaderSet creates a middleware that sets a single header
func AddLogging ¶
func AddLogging(config LoggingConfig) RequestHook
AddLogging creates a logging hook
func AddMetrics ¶
func AddMetrics(collector *MetricsCollector) RequestHook
AddMetrics creates a metrics collection middleware
func AddRequestID ¶
func AddRequestID(config RequestIDConfig) RequestHook
AddRequestID creates a request ID middleware
func AddSecurityHeaders ¶
func AddSecurityHeaders() RequestHook
AddSecurityHeaders creates a security headers middleware
func AddStructuredLogging ¶
func AddStructuredLogging(config LoggingConfig) RequestHook
AddStructuredLogging creates a structured logging middleware
func AddTracing ¶
func AddTracing(config RequestIDConfig) RequestHook
AddTracing creates a tracing middleware that propagates request ID
func AddUserAgent ¶
func AddUserAgent(userAgent string) RequestHook
AddUserAgent creates a user agent middleware
func AddValidation ¶
func AddValidation(validator Validator) RequestHook
AddValidation validates request payloads
type RequestIDConfig ¶
type RequestIDConfig struct {
Generator RequestIDGenerator
HeaderName string
ContextKey any
Propagate bool
}
RequestIDConfig configures request ID generation
func DefaultRequestIDConfig ¶
func DefaultRequestIDConfig() RequestIDConfig
DefaultRequestIDConfig returns a default request ID configuration
type RequestIDGenerator ¶
type RequestIDGenerator interface {
Generate() string
}
RequestIDGenerator generates unique request IDs
type RequestMetrics ¶
type RequestMetrics struct {
TotalRequests int64
SuccessfulRequests int64
FailedRequests int64
AverageResponseTime time.Duration
}
RequestMetrics provides a snapshot of insights into request performance
type RequestOptions ¶
type RequestOptions struct {
Headers http.Header
Query map[string]any
Timeout *time.Duration
Context context.Context
Retries *int
Body any // Request body (JSON, form data, io.Reader, BodyProvider)
// Per-request hooks (runs after client-level hooks)
RequestHooks []RequestHook
ResponseHooks []ResponseHook
// IdempotencyKey is used for request deduplication
// If set, concurrent requests with the same key will share the response
IdempotencyKey string
// DisableDedupe skips deduplication for this request
DisableDedupe bool
}
RequestOptions contains configuration for individual requests
type Response ¶
type Response[T any] struct { Data T StatusCode int Headers http.Header Raw *http.Response // contains filtered or unexported fields }
Response wraps HTTP response data with type safety
func DoWithType ¶
func DoWithType[T any](client *Client, method HTTPMethod, path string, opts ...*RequestOptions) (*Response[T], error)
DoWithType executes a request and unmarshals the response to the specified type
func Execute ¶
func Execute[TRequest any, TResponse any]( client *Client, route Route[TRequest, TResponse], request TRequest, options *RequestOptions, ) (*Response[TResponse], error)
Execute performs a type-safe HTTP request
func (*Response[T]) IsClientError ¶
IsClientError returns true if the status code is in the 4xx range
func (*Response[T]) IsServerError ¶
IsServerError returns true if the status code is in the 5xx range
type ResponseHook ¶
ResponseHook processes responses after they are received
func AddRateLimitHandler ¶
func AddRateLimitHandler(updater RateLimitUpdater) ResponseHook
AddRateLimitHandler creates a response hook that parses rate limit headers and updates the provided RateLimitUpdater with the current rate limit state.
func AddRateLimitLogging ¶
func AddRateLimitLogging(logFn func(method, path string, info *RateLimitInfo)) ResponseHook
AddRateLimitLogging creates a response hook that logs rate limit information. The logFn receives the method, path, and parsed rate limit info.
func AddRateLimitRetry ¶
func AddRateLimitRetry() ResponseHook
AddRateLimitRetry creates a response hook that returns an error on 429 responses. The error can be used to trigger automatic retry logic at the client level. For automatic 429 handling, use ClientOptions.AutoHandleRateLimit instead.
func AddResponseCache ¶
func AddResponseCache(cache Cache) ResponseHook
AddResponseCache implements response caching
func AddResponseCompression ¶
func AddResponseCompression(config CompressionConfig) ResponseHook
AddResponseCompression creates a response compression middleware
func AddResponseDebug ¶
func AddResponseDebug(config LoggingConfig) ResponseHook
AddResponseDebug creates a debug response logging middleware
func AddResponseDecompression ¶
func AddResponseDecompression() ResponseHook
AddResponseDecompression creates a response decompression middleware
func AddResponseErrorLogging ¶
func AddResponseErrorLogging(config LoggingConfig) ResponseHook
AddResponseErrorLogging creates an error logging middleware
func AddResponseLogging ¶
func AddResponseLogging(config LoggingConfig) ResponseHook
AddResponseLogging creates a response logging middleware
func AddResponseMetrics ¶
func AddResponseMetrics(collector *MetricsCollector) ResponseHook
AddResponseMetrics creates a response metrics collection middleware
func AddResponseRequestID ¶
func AddResponseRequestID(config RequestIDConfig) ResponseHook
AddResponseRequestID creates a response middleware that logs request ID
func AddResponseStructured ¶
func AddResponseStructured(config LoggingConfig) ResponseHook
AddResponseStructured creates a structured response logging middleware
func AddResponseTimeout ¶
func AddResponseTimeout(timeout time.Duration) ResponseHook
AddResponseTimeout creates a response timeout middleware that checks if a request took too long.
type Route ¶
type Route[TRequest, TResponse any] struct { Method HTTPMethod Path string }
Route represents a type-safe route definition
type SequentialGenerator ¶
type SequentialGenerator struct {
// contains filtered or unexported fields
}
SequentialGenerator generates sequential request IDs
func (*SequentialGenerator) Generate ¶
func (g *SequentialGenerator) Generate() string
Generate creates a sequential request ID
type Serializable ¶
Serializable represents types that can be serialized for requests
type StaticAuthProvider ¶
StaticAuthProvider provides static token authentication
func (*StaticAuthProvider) GetAuthHeader ¶
func (a *StaticAuthProvider) GetAuthHeader(token string) string
type TimestampGenerator ¶
type TimestampGenerator struct{}
TimestampGenerator generates timestamp-based request IDs
func (*TimestampGenerator) Generate ¶
func (g *TimestampGenerator) Generate() string
Generate creates a timestamp-based request ID
type UUIDGenerator ¶
type UUIDGenerator struct{}
UUIDGenerator generates UUID-style request IDs
func (*UUIDGenerator) Generate ¶
func (g *UUIDGenerator) Generate() string
Generate creates a new UUID-style request ID
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
neuron-cli
command
|
|
|
internal
|
|
|
Package mock provides testing utilities and mocks for the neuron HTTP client library.
|
Package mock provides testing utilities and mocks for the neuron HTTP client library. |