98e24e202d
Signed-off-by: Ciro S. Costa <utxobr@protonmail.com>
24 lines
416 B
Go
24 lines
416 B
Go
package http
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// NewHTTPClient instantiates a new `http.Client` with a few defaults.
|
|
//
|
|
// `verbose`: if set, adds a transport that dumps all requests and responses to
|
|
// stdout.
|
|
//
|
|
func NewHTTPClient(verbose bool) *http.Client {
|
|
client := &http.Client{
|
|
Timeout: 15 * time.Second,
|
|
}
|
|
|
|
if verbose {
|
|
client.Transport = NewDumpTransport(http.DefaultTransport)
|
|
}
|
|
|
|
return client
|
|
}
|