httpclient

package
v0.115.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 8 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. Use when a third-party library needs a transport rather than a full http.Client.

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