Documentation
¶
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Delete(url string, options ...RequestOption) (*Response, error)
- func (c *Client) Get(url string, options ...RequestOption) (*Response, error)
- func (c *Client) Head(url string, options ...RequestOption) (*Response, error)
- func (c *Client) Options(url string, options ...RequestOption) (*Response, error)
- func (c *Client) Patch(url string, options ...RequestOption) (*Response, error)
- func (c *Client) Post(url string, options ...RequestOption) (*Response, error)
- func (c *Client) Put(url string, options ...RequestOption) (*Response, error)
- func (c *Client) Request(ctx context.Context, method, url string, options ...RequestOption) (*Response, error)
- type ClientError
- type Config
- type ErrorType
- type FileDataExtractor
- type FormDataExtractor
- type Request
- type RequestOption
- type RequestProcessor
- type Response
- type ResponseProcessor
- type RetryEngine
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the core HTTP client engine with optimal performance
func (*Client) Delete ¶
func (c *Client) Delete(url string, options ...RequestOption) (*Response, error)
func (*Client) Head ¶
func (c *Client) Head(url string, options ...RequestOption) (*Response, error)
func (*Client) Options ¶
func (c *Client) Options(url string, options ...RequestOption) (*Response, error)
func (*Client) Patch ¶
func (c *Client) Patch(url string, options ...RequestOption) (*Response, error)
type ClientError ¶
type ClientError struct {
Type ErrorType
Message string
Cause error
URL string
Method string
Attempts int
StatusCode int // HTTP status code if applicable
Host string // Host for circuit breaker errors
}
func ClassifyError ¶
func ClassifyError(err error, url, method string, attempts int) *ClientError
func (*ClientError) Code ¶
func (e *ClientError) Code() string
Code returns a string error code for programmatic handling
func (*ClientError) Error ¶
func (e *ClientError) Error() string
func (*ClientError) IsRetryable ¶
func (e *ClientError) IsRetryable() bool
func (*ClientError) Unwrap ¶
func (e *ClientError) Unwrap() error
type Config ¶
type Config struct {
// Network settings
Timeout time.Duration
DialTimeout time.Duration
KeepAlive time.Duration
TLSHandshakeTimeout time.Duration
ResponseHeaderTimeout time.Duration
IdleConnTimeout time.Duration
MaxIdleConns int
MaxIdleConnsPerHost int
MaxConnsPerHost int
ProxyURL string
// Security settings
TLSConfig interface{} // *tls.Config
MinTLSVersion uint16
MaxTLSVersion uint16
InsecureSkipVerify bool
MaxResponseBodySize int64
MaxConcurrentRequests int
ValidateURL bool
ValidateHeaders bool
AllowPrivateIPs bool
// Retry settings
MaxRetries int
RetryDelay time.Duration
MaxRetryDelay time.Duration
BackoffFactor float64
Jitter bool
// Headers and features
UserAgent string
Headers map[string]string
FollowRedirects bool
EnableHTTP2 bool
// Cookie settings
CookieJar interface{} // http.CookieJar
EnableCookies bool
}
Config represents the unified client configuration
type FileDataExtractor ¶
type FormDataExtractor ¶
type FormDataExtractor struct {
Fields map[string]string
Files map[string]*FileDataExtractor
}
type Request ¶
type Request struct {
Method string
URL string
Headers map[string]string
QueryParams map[string]any
Body any
Timeout time.Duration
MaxRetries int
Context context.Context
Cookies []*http.Cookie
}
Request represents an HTTP request
type RequestOption ¶
type RequestOption func(*Request)
type RequestProcessor ¶
type RequestProcessor struct {
// contains filtered or unexported fields
}
func NewRequestProcessor ¶
func NewRequestProcessor(config *Config, memManager *memory.Manager) *RequestProcessor
type Response ¶
type Response struct {
StatusCode int
Status string
Headers map[string][]string
Body string
RawBody []byte
ContentLength int64
Proto string
Duration time.Duration
Attempts int
Request interface{}
Response interface{}
Cookies []*http.Cookie
}
Response represents an HTTP response
type ResponseProcessor ¶
type ResponseProcessor struct {
// contains filtered or unexported fields
}
ResponseProcessor handles HTTP response processing
func NewResponseProcessor ¶
func NewResponseProcessor(config *Config, memManager *memory.Manager) *ResponseProcessor
NewResponseProcessor creates a new response processor with memory management
type RetryEngine ¶
type RetryEngine struct {
// contains filtered or unexported fields
}
RetryEngine handles retry logic with exponential backoff
func NewRetryEngine ¶
func NewRetryEngine(config *Config) *RetryEngine
NewRetryEngine creates a new retry engine
func (*RetryEngine) GetDelay ¶
func (r *RetryEngine) GetDelay(attempt int) time.Duration
GetDelay calculates the delay for the next retry attempt
func (*RetryEngine) MaxRetries ¶
func (r *RetryEngine) MaxRetries() int
MaxRetries returns the maximum number of retry attempts
func (*RetryEngine) ShouldRetry ¶
func (r *RetryEngine) ShouldRetry(resp *Response, err error, attempt int) bool
ShouldRetry determines if a request should be retried
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport manages HTTP transport with comprehensive security and optimal performance
func NewTransport ¶
func NewTransport(config *Config, pool *connection.PoolManager) (*Transport, error)
NewTransport creates a new transport manager with connection pool