Skip to content

Commit

Permalink
Merge pull request #12 from cameront/master
Browse files Browse the repository at this point in the history
allow setting http client to something non-default
  • Loading branch information
mihasya authored Dec 27, 2017
2 parents 0ec8d5e + 1bdf70c commit c2a1624
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ type Batch struct {
Source string `json:"source"`
}

var client = http.DefaultClient

func SetHTTPClient(c *http.Client) {
client = c
}

func (self *LibratoClient) PostMetrics(batch Batch) (err error) {
var (
js []byte
Expand All @@ -87,7 +93,7 @@ func (self *LibratoClient) PostMetrics(batch Batch) (err error) {
req.Header.Set("Content-Type", "application/json")
req.SetBasicAuth(self.Email, self.Token)

if resp, err = http.DefaultClient.Do(req); err != nil {
if resp, err = client.Do(req); err != nil {
return
}
defer resp.Body.Close()
Expand Down

0 comments on commit c2a1624

Please sign in to comment.