http

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHttpClient

func NewHttpClient(c *HttpClientConfig, logger hclog.Logger, clientCerts []tls.Certificate) *http.Client

func NewHttpTransport

func NewHttpTransport(c *HttpClientConfig, logger hclog.Logger, clientCerts []tls.Certificate) http.RoundTripper

NewHttpClient Create new http.Transport initialize according to HttpClientConfig

func NewLogTransport

func NewLogTransport(transport *http.Transport, logger hclog.Logger) http.RoundTripper

Types

type HttpClientConfig

type HttpClientConfig struct {
	// MaxIdleConns controls the maximum number of idle (keep-alive)
	// connections across all hosts. Zero means no limit.
	MaxIdleConns int `yaml:"max_idle_conns" default:"10" `

	// MaxIdleConnsPerHost, if non-zero, controls the maximum idle
	// (keep-alive) connections to keep per-host. If zero,
	// DefaultMaxIdleConnsPerHost is used.
	MaxIdleConnsPerHost int `yaml:"max_idle_conns_per_host" default:"10" `

	// Zero means no limit.
	MaxConnsPerHost int `yaml:"max_conns_per_host"  default:"10" `

	// The Client cancels requests to the underlying Transport
	// as if the Request's Context ended.
	Timeout time.Duration `yaml:"timeout_duration" default:"10s"`

	InsecureSkipVerify bool `yaml:"skip_tls_verification" default:"false"`

	MaxRespSizeLimitBytes int64 `yaml:"limit_max_resp_size_limit" default:"60000"`

	ExtraHeader map[string]string `yaml:"extra_headers"`
}

func NewDefaultHttpClientCfg

func NewDefaultHttpClientCfg() *HttpClientConfig

NewDefaultHttpClientCfg create a default config

func (*HttpClientConfig) UnmarshalYAML

func (c *HttpClientConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type LogTransport

type LogTransport struct {
	// contains filtered or unexported fields
}

func (*LogTransport) RoundTrip

func (t *LogTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is the core part of this module and implements http.RoundTripper. Executes HTTP request with request/response logging.

Jump to

Keyboard shortcuts

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