httpclient

package
v0.116.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const RetryCount = 3

Variables

This section is empty.

Functions

func DefaultTransport added in v0.115.0

func DefaultTransport() http.RoundTripper

DefaultTransport returns a RoundTripper with retry and proxy support. When HTTP caching is enabled via EnableHTTPCache, GET responses are served from cache: retryTransport -> cachingTransport -> otelhttp -> http.Transport.

func DisableHTTPCache added in v0.116.0

func DisableHTTPCache()

DisableHTTPCache deactivates the HTTP cache so that new clients no longer use it. Already-created clients may still hold a reference to the previous cache until they are garbage collected. Safe to call even if caching was never enabled.

func EnableHTTPCache added in v0.116.0

func EnableHTTPCache()

EnableHTTPCache activates in-memory caching of GET responses for all HTTP clients created via this package after this call. Call once before pipeline execution begins.

func NewPlainClient added in v0.115.0

func NewPlainClient() *http.Client

NewPlainClient returns an HTTP client with proxy support but no retry.

func NewRetryClient added in v0.84.1

func NewRetryClient() *http.Client

func NewThrottledRetryClient added in v0.115.0

func NewThrottledRetryClient(limitPeriod time.Duration, requestCount int) *http.Client

NewThrottledRetryClient returns an HTTP client with rate limiting wrapping retry + proxy.

func ProxyOnlyTransport added in v0.115.0

func ProxyOnlyTransport() http.RoundTripper

ProxyOnlyTransport returns a RoundTripper with proxy support but no retry. Use when the caller handles its own retry (e.g. go-containerregistry) or for non-idempotent operations (e.g. OAuth token exchange) where retry is unsafe.

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
	Get(url string) (*http.Response, error)
}

HTTPClient interface to define the contract of ALL http client to be used (http package or mocks)

type MockClient added in v0.19.0

type MockClient struct {
	DoFunc func(req *http.Request) (*http.Response, error)
}

MockClient is a stub implementation of an http.Client with a custom `Do` method

func (*MockClient) Do added in v0.19.0

func (m *MockClient) Do(req *http.Request) (*http.Response, error)

Do is the mock client's `Do` function that you can customize

func (*MockClient) Get added in v0.84.1

func (m *MockClient) Get(url string) (*http.Response, error)

Jump to

Keyboard shortcuts

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