mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-23 04:29:34 +01:00
.. | ||
.gitignore | ||
.travis.yml | ||
httpclient.go | ||
LICENSE | ||
README.md |
go-httpclient
requires Go 1.1+ as of v0.4.0
the API
has been completely re-written for Go 1.1 (for a Go 1.0.x compatible
release see 1adef50)
Provides an HTTP Transport that implements the
RoundTripper
interface and can be used as a built in
replacement for the standard library’s, providing:
- connection timeouts
- request timeouts
This is a thin wrapper around http.Transport
that sets
dial timeouts and uses Go’s internal timer scheduler to call the Go 1.1+
CancelRequest()
API.
Example
:= &httpclient.Transport{
transport : 1*time.Second,
ConnectTimeout: 10*time.Second,
RequestTimeout: 5*time.Second,
ResponseHeaderTimeout}
defer transport.Close()
:= &http.Client{Transport: transport}
client , _ := http.NewRequest("GET", "http://127.0.0.1/test", nil)
req, err := client.Do(req)
respif err != nil {
return err
}
defer resp.Body.Close()
Note: you will want to re-use a single client object rather than creating one for each request, otherwise you will end up leaking connections.
Reference Docs
For API docs see godoc.