HTTPClient is a zero dependency client which supports pluggable retry and pagination
Setup
go get -u github.com/pinpt/httpclient
Usage
The most basic usage which mimics http.Default:
httpclient.Default.Get("https://foo.com")
Customize the client by setting Config:
config := httpclient.NewConfig()
config.Retryable = httpclient.NewBackoffRetry(time.Millisecond, time.Millisecond*50, 10*time.Second, 2)
client := httpclient.NewHTTPClient(context.Background(), config, http.DefaultClient)
resp, err := client.Get("https://foo.com")
Pluggable
The httpclient package is very customizable. You can pass in any implementation of the Client interface which http.Client
implements. You can implement the Retryable and Paginator interfaces for customizing how to Retry failed requests and how to handle pagination.
License
Copyright © 2018-2019 by Pinpoint Software, Inc. MIT License. Pull requests welcome! 🙏🏻