• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..25-Jul-2019-

.gitignoreH A D25-Jul-201928 44

.travis.ymlH A D25-Jul-2019104 138

LICENSEH A D25-Jul-201915.5 KiB364265

MakefileH A D25-Jul-2019145 128

README.mdH A D25-Jul-20191.9 KiB4736

client.goH A D25-Jul-201917.4 KiB550326

go.modH A D25-Jul-201995 42

go.sumH A D25-Jul-2019185 32

README.md

1go-retryablehttp
2================
3
4[![Build Status](http://img.shields.io/travis/hashicorp/go-retryablehttp.svg?style=flat-square)][travis]
5[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs]
6
7[travis]: http://travis-ci.org/hashicorp/go-retryablehttp
8[godocs]: http://godoc.org/github.com/hashicorp/go-retryablehttp
9
10The `retryablehttp` package provides a familiar HTTP client interface with
11automatic retries and exponential backoff. It is a thin wrapper over the
12standard `net/http` client library and exposes nearly the same public API. This
13makes `retryablehttp` very easy to drop into existing programs.
14
15`retryablehttp` performs automatic retries under certain conditions. Mainly, if
16an error is returned by the client (connection errors, etc.), or if a 500-range
17response code is received (except 501), then a retry is invoked after a wait
18period.  Otherwise, the response is returned and left to the caller to
19interpret.
20
21The main difference from `net/http` is that requests which take a request body
22(POST/PUT et. al) can have the body provided in a number of ways (some more or
23less efficient) that allow "rewinding" the request body if the initial request
24fails so that the full request can be attempted again. See the
25[godoc](http://godoc.org/github.com/hashicorp/go-retryablehttp) for more
26details.
27
28Example Use
29===========
30
31Using this library should look almost identical to what you would do with
32`net/http`. The most simple example of a GET request is shown below:
33
34```go
35resp, err := retryablehttp.Get("/foo")
36if err != nil {
37    panic(err)
38}
39```
40
41The returned response object is an `*http.Response`, the same thing you would
42usually get from `net/http`. Had the request failed one or more times, the above
43call would block and retry with exponential backoff.
44
45For more usage and examples see the
46[godoc](http://godoc.org/github.com/hashicorp/go-retryablehttp).
47