Skip to content

Commit 8804914

Browse files
committed
Removed executor thing, it had no value because we don't use the mock
1 parent 74c575b commit 8804914

File tree

3 files changed

+7
-134
lines changed

3 files changed

+7
-134
lines changed

httpclient/client.go

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,19 @@ package httpclient
99

1010
import (
1111
"fmt"
12-
"io"
1312
"net/http"
1413
"net/http/cookiejar"
15-
"net/url"
1614
"time"
1715

1816
"github.com/deploymenttheory/go-api-http-client/concurrency"
1917
"go.uber.org/zap"
2018
)
2119

22-
// HTTPExecutor is an interface which wraps http.Client to allow mocking.
23-
type HTTPExecutor interface {
24-
25-
// Inherited
26-
CloseIdleConnections()
27-
Do(req *http.Request) (*http.Response, error)
28-
Get(url string) (resp *http.Response, err error)
29-
Head(url string) (resp *http.Response, err error)
30-
Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)
31-
PostForm(url string, data url.Values) (resp *http.Response, err error)
32-
33-
// Additional
34-
SetCookieJar(jar http.CookieJar)
35-
SetCookies(url *url.URL, cookies []*http.Cookie)
36-
SetCustomTimeout(time.Duration)
37-
Cookies(*url.URL) []*http.Cookie
38-
SetRedirectPolicy(*func(req *http.Request, via []*http.Request) error)
39-
}
40-
4120
// Master struct/object
4221
type Client struct {
4322
config *ClientConfig
4423
Integration *APIIntegration
45-
http HTTPExecutor
24+
http *http.Client
4625
Sugar *zap.SugaredLogger
4726
Concurrency *concurrency.ConcurrencyHandler
4827
}
@@ -100,7 +79,7 @@ type ClientConfig struct {
10079
// RetryEligiableRequests when false bypasses any retry logic for a simpler request flow.
10180
RetryEligiableRequests bool `json:"retry_eligiable_requests"`
10281

103-
HTTPExecutor HTTPExecutor
82+
HTTPExecutor http.Client
10483
}
10584

10685
// BuildClient creates a new HTTP client with the provided configuration.
@@ -131,10 +110,10 @@ func (c *ClientConfig) Build() (*Client, error) {
131110
return nil, err
132111
}
133112

134-
httpClient.SetCookieJar(cookieJar)
113+
httpClient.Jar = cookieJar
135114

136115
if c.CustomRedirectPolicy != nil {
137-
httpClient.SetRedirectPolicy(c.CustomRedirectPolicy)
116+
httpClient.CheckRedirect = *c.CustomRedirectPolicy
138117
}
139118

140119
// TODO refactor concurrency
@@ -150,7 +129,7 @@ func (c *ClientConfig) Build() (*Client, error) {
150129

151130
client := &Client{
152131
Integration: &c.Integration,
153-
http: httpClient,
132+
http: &httpClient,
154133
config: c,
155134
Sugar: c.Sugar,
156135
Concurrency: concurrencyHandler,

httpclient/cookies.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ func (c *Client) loadCustomCookies() error {
1212
return err
1313
}
1414

15-
c.http.SetCookies(cookieUrl, c.config.CustomCookies)
15+
c.http.Jar.SetCookies(cookieUrl, c.config.CustomCookies)
1616

1717
if c.config.HideSensitiveData {
1818
c.Sugar.Debug("[REDACTED] cookies set successfully")
1919
} else {
20-
c.Sugar.Debug("custom cookies set: %v", c.http.Cookies(cookieUrl))
20+
c.Sugar.Debug("custom cookies set: %v", c.http.Jar.Cookies(cookieUrl))
2121
}
2222

2323
return nil

httpclient/http.go

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)