From 93c7fc6f0768cdb9a5b67c846acb724e60235808 Mon Sep 17 00:00:00 2001 From: linlonghui Date: Thu, 10 Feb 2022 17:46:46 +0800 Subject: [PATCH] support configure HostClient --- client.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client.go b/client.go index cea718d24b..b36ca40824 100644 --- a/client.go +++ b/client.go @@ -297,6 +297,9 @@ type Client struct { // By default will use isIdempotent function RetryIf RetryIfFunc + // ConfigureClient configures the fasthttp.HostClient. + ConfigureClient func(hc *HostClient) error + mLock sync.Mutex m map[string]*HostClient ms map[string]*HostClient @@ -510,6 +513,13 @@ func (c *Client) Do(req *Request, resp *Response) error { clientReaderPool: &c.readerPool, clientWriterPool: &c.writerPool, } + + if c.ConfigureClient != nil { + if err := c.ConfigureClient(hc); err != nil { + return err + } + } + m[string(host)] = hc if len(m) == 1 { startCleaner = true