Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 25-Jul-2019 | - | ||||
.gitignore | H A D | 25-Jul-2019 | 28 | 4 | 4 | |
.travis.yml | H A D | 25-Jul-2019 | 104 | 13 | 8 | |
LICENSE | H A D | 25-Jul-2019 | 15.5 KiB | 364 | 265 | |
Makefile | H A D | 25-Jul-2019 | 145 | 12 | 8 | |
README.md | H A D | 25-Jul-2019 | 1.9 KiB | 47 | 36 | |
client.go | H A D | 25-Jul-2019 | 17.4 KiB | 550 | 326 | |
go.mod | H A D | 25-Jul-2019 | 95 | 4 | 2 | |
go.sum | H A D | 25-Jul-2019 | 185 | 3 | 2 |
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