Documentation ¶
Overview ¶
Package httputil implements utility for httpClient with request retry and optional tracing
Index ¶
- Variables
- type Backoff
- type CheckRetry
- type HTTPClient
- func New(log log.Log, tr Tracer, c *http.Client, retryMax int, ...) *HTTPClient
- func NewDefaultHTTPClient(log log.Log, t Tracer) *HTTPClient
- func NewH2CClient(log log.Log, tr Tracer, retryMax int, retryWaitMin, retryWaitMax time.Duration) *HTTPClient
- func NewHTTPClient(log log.Log, tr Tracer, retryMax int, retryWaitMin, retryWaitMax time.Duration) *HTTPClient
- func (h *HTTPClient) Call(ctx context.Context, method, url string, reqBody, resBody interface{}, ...) (*http.Response, error)
- func (h *HTTPClient) Decode(ctx context.Context, body []byte, data interface{}) (io.ReadCloser, error)
- func (h *HTTPClient) Delete(ctx context.Context, url string, reqBody, resBody interface{}, ...) (*http.Response, error)
- func (h *HTTPClient) Do(req *http.Request) (*http.Response, error)
- func (h *HTTPClient) Encode(ctx context.Context, data interface{}) (io.Reader, error)
- func (h *HTTPClient) Get(ctx context.Context, url string, reqBody, resBody interface{}, ...) (*http.Response, error)
- func (h *HTTPClient) Patch(ctx context.Context, url string, reqBody, resBody interface{}, ...) (*http.Response, error)
- func (h *HTTPClient) Post(ctx context.Context, url string, reqBody, resBody interface{}, ...) (*http.Response, error)
- func (h *HTTPClient) Put(ctx context.Context, url string, reqBody, resBody interface{}, ...) (*http.Response, error)
- type Tracer
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrResponseFromUpstream = fmt.Errorf("HttpClient.Call: non 2xx status")
View Source
var ErrResponseUnmarshal = fmt.Errorf("error marshalling response body")
Functions ¶
This section is empty.
Types ¶
type CheckRetry ¶
type HTTPClient ¶
func New ¶
func New(log log.Log, tr Tracer, c *http.Client, retryMax int, retryWaitMin, retryWaitMax time.Duration) *HTTPClient
New creates a new HTTPClient wrapper for passed *http.Client
func NewDefaultHTTPClient ¶
func NewDefaultHTTPClient(log log.Log, t Tracer) *HTTPClient
NewDefaultHTTPClient creates a new HTTPClient with default options
func NewH2CClient ¶
func NewH2CClient(log log.Log, tr Tracer, retryMax int, retryWaitMin, retryWaitMax time.Duration) *HTTPClient
NewH2CClient creates a new HTTPClient with configuration to support h2c servers
func NewHTTPClient ¶
func NewHTTPClient(log log.Log, tr Tracer, retryMax int, retryWaitMin, retryWaitMax time.Duration) *HTTPClient
NewHTTPClient creates a new HTTPClient
func (*HTTPClient) Call ¶
func (h *HTTPClient) Call(ctx context.Context, method, url string, reqBody, resBody interface{}, headers map[string]string) (*http.Response, error)
Call pre-processes the request and response
func (*HTTPClient) Decode ¶
func (h *HTTPClient) Decode(ctx context.Context, body []byte, data interface{}) (io.ReadCloser, error)
Decode un-marshals the passed bytes to an object and returns a copy in io.ReadCloser
func (*HTTPClient) Delete ¶
func (h *HTTPClient) Delete(ctx context.Context, url string, reqBody, resBody interface{}, headers map[string]string) (*http.Response, error)
Delete HTTP DELETE method invocation
func (*HTTPClient) Get ¶
func (h *HTTPClient) Get(ctx context.Context, url string, reqBody, resBody interface{}, headers map[string]string) (*http.Response, error)
Get HTTP GET method invocation
func (*HTTPClient) Patch ¶
func (h *HTTPClient) Patch(ctx context.Context, url string, reqBody, resBody interface{}, headers map[string]string) (*http.Response, error)
Patch HTTP PATCH method invocation
type Tracer ¶
type Tracer interface { HTTPWrapTransport(http.RoundTripper) http.RoundTripper HTTPRequestTrace(context.Context) *httptrace.ClientTrace span.SpanOp }
Click to show internal directories.
Click to hide internal directories.