Documentation
¶
Index ¶
Constants ¶
View Source
const ModuleName = "httpfx"
Variables ¶
View Source
var ( // ErrInvalidConfig is returned when the HTTP client configuration is invalid. ErrInvalidConfig = errors.New("invalid config") // ErrInvalidProxyURL is returned when the proxy URL cannot be parsed. ErrInvalidProxyURL = errors.New("invalid proxy URL") // ErrProxyDialFailed is returned when the proxy dialer cannot be created. ErrProxyDialFailed = errors.New("proxy dialer creation failed") )
Functions ¶
Types ¶
type Config ¶
type Config struct {
// ProxyURL is an explicit SOCKS5 proxy URL (e.g., "socks5://user:pass@host:port").
// Empty means no proxy. Takes precedence over ProxyFromEnv.
ProxyURL string
// ProxyFromEnv enables reading the proxy from the ALL_PROXY environment variable.
// Used only when ProxyURL is empty.
ProxyFromEnv bool
// Bypass is a comma-separated list of hosts that bypass the proxy
// (e.g., "localhost,127.0.0.1").
Bypass string
// Timeout is the HTTP client-level timeout. Zero means no timeout.
Timeout time.Duration
// MaxIdleConns is the maximum number of idle (keep-alive) connections.
// Zero means no limit.
MaxIdleConns int
// MaxIdleConnsPerHost is the maximum idle connections per host.
// Zero means DefaultMaxIdleConnsPerHost (2).
MaxIdleConnsPerHost int
// IdleConnTimeout is the maximum time an idle connection is kept alive.
// Zero means no timeout.
IdleConnTimeout time.Duration
}
Config holds the HTTP client configuration.
type Factory ¶
type Factory interface {
// NewClient creates a new [http.Client] using the factory's base configuration,
// with optional per-client overrides via [Option].
NewClient(opts ...Option) *http.Client
}
Factory creates http.Client instances with shared proxy and transport configuration.
type Option ¶
type Option func(*clientOptions)
Option configures per-client overrides on Factory.NewClient.
func WithBypass ¶
WithBypass overrides the proxy bypass list for this client.
func WithIdleConnTimeout ¶
WithIdleConnTimeout overrides the idle connection timeout for this client.
func WithMaxIdleConns ¶
WithMaxIdleConns overrides the maximum idle connections for this client.
func WithMaxIdleConnsPerHost ¶
WithMaxIdleConnsPerHost overrides the maximum idle connections per host for this client.
func WithProxyFromEnv ¶
WithProxyFromEnv overrides the ProxyFromEnv flag for this client.
func WithProxyURL ¶
WithProxyURL overrides the SOCKS5 proxy URL for this client.
func WithTimeout ¶
WithTimeout overrides the client-level timeout for this client.
Click to show internal directories.
Click to hide internal directories.