Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Delete(ctx context.Context, url string, headers http.Header) (*http.Response, error)
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) Get(ctx context.Context, url string, headers http.Header) (*http.Response, error)
- func (c *Client) Patch(ctx context.Context, url string, body io.Reader, headers http.Header) (*http.Response, error)
- func (c *Client) Post(ctx context.Context, url string, body io.Reader, headers http.Header) (*http.Response, error)
- func (c *Client) Put(ctx context.Context, url string, body io.Reader, headers http.Header) (*http.Response, error)
- type Doer
- type Option
- type RequestCreationError
- type Retrier
- type RetryPolicy
Constants ¶
This section is empty.
Variables ¶
var ErrStatusCode = errors.New("status code internal error")
ErrStatusCode is used internally to be able to differentiate between an actual error from the underlying HTTP client and an error that is returned for to retry retryable HTTP codes (from policy).
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client composes a Doer and a Retrier. By default, the client uses:
- a http.Client with a timeout set to 60 * time.Second
- a retrier that does not retry
- a retry policy that return false for all HTTP codes
func (*Client) Delete ¶
func (c *Client) Delete(ctx context.Context, url string, headers http.Header) (*http.Response, error)
Delete makes a HTTP DELETE request to provided URL.
func (*Client) Patch ¶
func (c *Client) Patch(ctx context.Context, url string, body io.Reader, headers http.Header) (*http.Response, error)
Patch makes a HTTP PATCH request to provided URL.
type Option ¶
type Option func(*Client)
Option represents the client options.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
func WithRetrier ¶
WithRetrier sets the strategy for retrying.
func WithRetryPolicy ¶
func WithRetryPolicy(retryPolicy RetryPolicy) Option
WithRetryPolicy sets the retry policy.
type RequestCreationError ¶
type RequestCreationError struct {
Err error
}
RequestCreationError is used to signal the request creation failed.
func (*RequestCreationError) Error ¶
func (e *RequestCreationError) Error() string
Error returns the error message.
type RetryPolicy ¶
RetryPolicy describes the retry policy based on HTTP codes. It should return true for retryable HTTP code and false otherwise.