Help us shape the future of Go! Take the 2026 Go Developer Survey

httpclient

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHTTPClient

func BuildHTTPClient(config NetworkConfig) *http.Client

BuildHTTPClient constructs a shared HTTP client from the network config.

Types

type NetworkConfig

type NetworkConfig struct {
	// RequestTimeoutSeconds is the per-request HTTP timeout. Default: 120.
	RequestTimeoutSeconds int `json:"request_timeout_seconds,omitempty"`
	// MaxRetries is the number of automatic retries on transient errors. Default: 3.
	MaxRetries int `json:"max_retries,omitempty"`
	// RetryDelaySeconds is the base delay between retries. Default: 1.
	RetryDelaySeconds int `json:"retry_delay_seconds,omitempty"`
	// MaxIdleConnections is the maximum number of idle keep-alive connections across all hosts. Default: 100.
	MaxIdleConnections int `json:"max_idle_connections,omitempty"`
	// MaxIdleConnectionsPerHost is the maximum number of idle keep-alive connections to keep per host. Default: 20.
	MaxIdleConnectionsPerHost int `json:"max_idle_connections_per_host,omitempty"`
	// IdleKeepAliveTimeoutSeconds is how long an idle keep-alive connection remains reusable before closing. Default: 90.
	IdleKeepAliveTimeoutSeconds int `json:"idle_keep_alive_timeout_seconds,omitempty"`
	// ProxyURL is an optional HTTP/HTTPS/SOCKS5 proxy URL.
	ProxyURL string `json:"proxy_url,omitempty"`
	// ExtraHeaders are additional HTTP headers sent with every request.
	ExtraHeaders map[string]string `json:"extra_headers,omitempty"`
}

NetworkConfig controls shared HTTP client behavior.

func (*NetworkConfig) Defaults

func (c *NetworkConfig) Defaults()

Defaults fills in zero values with sensible defaults.

func (*NetworkConfig) IdleKeepAliveTimeout

func (c *NetworkConfig) IdleKeepAliveTimeout() time.Duration

IdleKeepAliveTimeout returns the configured idle keep-alive timeout as a time.Duration.

func (*NetworkConfig) RequestTimeout

func (c *NetworkConfig) RequestTimeout() time.Duration

RequestTimeout returns the configured request timeout as a time.Duration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL