Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MockHTTPResponse ¶
MockHTTPResponse is a helper that returns a mocked http.Response with the provided httpStatus and body.
func NewHTTPClient ¶
func NewHTTPClient(opts HTTPClientOptions) *http.Client
NewHTTPClient returns an http.Client configured with HTTPClientOptions.
Types ¶
type HTTPClient ¶
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
Get(url string) (*http.Response, error)
Head(url string) (*http.Response, error)
}
HTTPClient interface for http.Client.
type HTTPClientMock ¶
HTTPClientMock implements a mock for the HTTPClient interface.
func (*HTTPClientMock) Do ¶
Do is a mock that tracks the calls to Do and returns the mocked http.Response and error.
type HTTPClientOptions ¶
type HTTPClientOptions struct {
AttemptTimeout *time.Duration // AttemptTimeout is how long each request waits before cancelled.
Backoff *time.Duration // Backoff is a constant duration to wait between requests.
Retries int // Retries for a request, if 0 then no retry logic is added.
RetryErrorCodes []string // RetryErrorCode is list of error codes to retry on.
RetryStatusCodes []int // RetryStatusCode is list of http status codes to retry on.
SkipTLSVerify bool // SkipTLSVerify will skip verifying the host's certificate.
TotalTimeOut time.Duration // TotalTimeOut for the life of the request (default: defaultTotalTimeout).
}
HTTPClientOptions allows for the customization of a http.Client.
Click to show internal directories.
Click to hide internal directories.