From afe9b696c5d0c8d034b485c1b8fcc1c4b71aff3f Mon Sep 17 00:00:00 2001 From: Ilya Glotov Date: Tue, 25 Jun 2019 17:07:24 +0300 Subject: [PATCH] Add option to specify http client --- cortex.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cortex.go b/cortex.go index 84e8750..aa1f745 100644 --- a/cortex.go +++ b/cortex.go @@ -86,9 +86,10 @@ type Client struct { Users UserService } -// ClientOpts represent options that are passed to client +// ClientOpts represent options that are passed to client. type ClientOpts struct { - Auth auth + Auth auth + HTTPClient *http.Client } // errorMessage is the message that Cortex sends back to user when something @@ -105,8 +106,12 @@ func NewClient(baseurl string, opts *ClientOpts) (*Client, error) { return nil, err } + if opts.HTTPClient != nil { + opts.HTTPClient = http.DefaultClient + } + c := &Client{ - Client: http.DefaultClient, + Client: opts.HTTPClient, BaseURL: u, UserAgent: userAgent, Opts: opts,