From 2f5017452f00af533d35e4f10040fcb882a2a976 Mon Sep 17 00:00:00 2001 From: Pavel Date: Fri, 18 Oct 2019 17:02:41 +0300 Subject: [PATCH] Feature: initialization with provided http client --- v1/client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/v1/client.go b/v1/client.go index c0fe95a..2993c55 100644 --- a/v1/client.go +++ b/v1/client.go @@ -15,10 +15,15 @@ import ( // New initialize client func New(url string, token string) *MgClient { + return NewWithClient(url, token, &http.Client{Timeout: time.Minute}) +} + +// NewWithClient initializes client with provided http client +func NewWithClient(url string, token string, client *http.Client) *MgClient { return &MgClient{ URL: url, Token: token, - httpClient: &http.Client{Timeout: time.Minute}, + httpClient: client, } }