Skip to content

Support wrapped http Clients using a HTTP client interface instead of the concrete http.Client #87

@nitishm

Description

@nitishm

The standard library doesn't support features like Retry of error and different backoff strategies for the same. The recommended approach is to wrap the standard library HTTP client package with any custom handling logic. (See ianlancetaylor's reponse in golang/go#16047)
I propose adding an HTTPClient interface with the same method signatures as the standard library HTTP Client

    type Client
        func (c *Client) CloseIdleConnections()
        func (c *Client) Do(req *Request) (*Response, error)
        func (c *Client) Get(url string) (resp *Response, err error)
        func (c *Client) Head(url string) (resp *Response, err error)
        func (c *Client) Post(url, contentType string, body io.Reader) (resp *Response, err error)
        func (c *Client) PostForm(url string, data url.Values) (resp *Response, err error)

Added a PR for the same #86

Please let me know if this makes sense and can be supported. Would really benefit our team in adding retry mechanism to the client for all requests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions