Documentation ¶
Index ¶
- Constants
- func Delete(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
- func Get(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
- func NewClient(opts ...Option) *client
- func Patch(url string, body io.Reader, headers http.Header, ...) (*http.Response, error)
- func Post(url string, body io.Reader, headers http.Header, ...) (*http.Response, error)
- func Put(url string, body io.Reader, headers http.Header, ...) (*http.Response, error)
- type Backoff
- type Client
- type Doer
- type Option
- type Retriable
- type RetriableFunc
Constants ¶
const (
// Profile is a http client profile.
Profile = "httpclient"
)
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
Delete makes a HTTP DELETE request with provided URL with default client
func Get ¶
func Get(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
Get makes a HTTP GET request to provided URL with default client
func NewClient ¶
func NewClient(opts ...Option) *client
NewClient returns a new instance of http client
func Patch ¶
func Patch(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error)
Patch makes a HTTP PATCH request to provided URL and requestBody with default client
Types ¶
type Backoff ¶
Backoff interface defines contract for backoff strategies
func NewConstantBackoff ¶
NewConstantBackoff returns an instance of ConstantBackoff
type Client ¶
type Client interface { Get(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error) Post(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error) Put(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error) Patch(url string, body io.Reader, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error) Delete(url string, headers http.Header, callbacks ...func(req *http.Request)) (*http.Response, error) Do(req *http.Request) (*http.Response, error) }
Client Is a generic HTTP client interface
type Doer ¶
Doer interface has the method required to use a type as custom http client. The net/*http.client type satisfies this interface.
type Option ¶
type Option func(*client)
Option represents the client options
func WithHTTPClient ¶
WithHTTPClient sets a custom http client
func WithHTTPTimeout ¶
WithHTTPTimeout sets hystrix timeout
func WithRetrier ¶
WithRetrier sets the strategy for retrying
type Retriable ¶
Retriable defines contract for retriers to implement
func NewRetrier ¶
NewRetrier returns retrier with some backoff strategy
func NewRetrierFunc ¶
func NewRetrierFunc(f RetriableFunc) Retriable
NewRetrierFunc returns a retrier with a retrier function defined