From 2d3a2e695924467b54505aaeede4ca8e1d02d529 Mon Sep 17 00:00:00 2001 From: Satont <42675886+Satont@users.noreply.github.com> Date: Mon, 10 Apr 2023 10:10:24 +0300 Subject: [PATCH] feat(tg): accept any http client what satisfies doer interface (#120) * feat(tg): accept any http client what satisfies doer interface This will makes possible usage of github.com/hashicorp/go-retryablehttp, any any http client which relies on some internal things and have different from http.Client struct return, but satisfies http interface * feat: make doer interface public --- client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 01558ce..8b7ed83 100644 --- a/client.go +++ b/client.go @@ -11,7 +11,7 @@ import ( "sync" ) -type doer interface { +type Doer interface { Do(r *http.Request) (*http.Response, error) } @@ -30,7 +30,7 @@ type Client struct { // http client, // default values is http.DefaultClient - doer doer + doer Doer // contains cached bot info me *User @@ -48,7 +48,7 @@ func WithClientServerURL(server string) ClientOption { } // WithClientDoer sets custom http client for Client. -func WithClientDoer(doer *http.Client) ClientOption { +func WithClientDoer(doer Doer) ClientOption { return func(c *Client) { c.doer = doer }