client

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLoopback added in v0.19.0

func IsLoopback(host string) bool

IsLoopback returns true if the host is a loopback address. This includes "localhost" and IP addresses in the loopback range (127.0.0.0/8 for IPv4, ::1 for IPv6).

func WithRedirectCallback added in v0.15.0

func WithRedirectCallback(ctx context.Context, cb RedirectCallback) context.Context

WithRedirectCallback returns a context with a redirect callback.

Types

type Client

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

Client represents a wrapped HTTP client.

func NewClient

func NewClient(cfg ClientConfig) *Client

NewClient returns an initialized Client given the provided configuration.

func (*Client) Close added in v0.20.0

func (c *Client) Close() error

Close closes the underlying transport, releasing any resources.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do performs the provided http Request, returning the response.

func (*Client) HTTPClient added in v0.19.0

func (c *Client) HTTPClient() *http.Client

HTTPClient returns the underlying *http.Client.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, cfg RequestConfig) (*http.Request, error)

NewRequest returns an *http.Request given the provided configuration.

func (*Client) SetJar added in v0.17.0

func (c *Client) SetJar(jar http.CookieJar)

SetJar sets the cookie jar on the HTTP client.

type ClientConfig

type ClientConfig struct {
	CACerts        []*x509.Certificate
	ClientCert     *tls.Certificate
	ConnectTimeout time.Duration
	DNSServer      *url.URL
	H2C            bool
	HTTP           core.HTTPVersion
	Insecure       bool
	Proxy          *url.URL
	Redirects      *int
	TLSMax         uint16
	TLSMin         uint16
	UnixSocket     string
}

ClientConfig represents the optional configuration parameters for a Client.

type RedirectCallback added in v0.15.0

type RedirectCallback func(hop RedirectHop)

RedirectCallback is called when a redirect occurs.

type RedirectHop added in v0.15.0

type RedirectHop struct {
	Request     *http.Request  // The request that triggered the redirect
	Response    *http.Response // The redirect response (e.g., 302)
	NextRequest *http.Request  // The new request about to be made
}

RedirectHop represents a single redirect in the chain.

type RequestConfig

type RequestConfig struct {
	Basic       *core.KeyVal[string]
	Bearer      string
	ContentType string
	Data        io.Reader
	Form        []core.KeyVal[string]
	Headers     []core.KeyVal[string]
	HTTP        core.HTTPVersion
	Method      string
	Multipart   *multipart.Multipart
	NoEncode    bool
	QueryParams []core.KeyVal[string]
	Range       []string
	URL         *url.URL
}

RequestConfig represents the configuration for creating an HTTP request.

type TLSDialConfig added in v0.19.0

type TLSDialConfig struct {
	CACerts    []*x509.Certificate
	ClientCert *tls.Certificate
	Insecure   bool
	TLSMax     uint16
	TLSMin     uint16
}

TLSDialConfig holds the common configuration for building a TLS config and dial function.

func (*TLSDialConfig) BuildTLSConfig added in v0.19.0

func (c *TLSDialConfig) BuildTLSConfig() *tls.Config

BuildTLSConfig returns a *tls.Config from the common configuration fields.

Jump to

Keyboard shortcuts

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