File tree 2 files changed +7
-11
lines changed
2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -36,18 +36,14 @@ var DefaultRoundTripper http.RoundTripper = &http.Transport{
36
36
TLSHandshakeTimeout : 10 * time .Second ,
37
37
}
38
38
39
- type HttpClient interface {
40
- Do (req * http.Request ) (* http.Response , error )
41
- }
42
-
43
39
// Config defines configuration parameters for a new client.
44
40
type Config struct {
45
41
// The address of the Prometheus to connect to.
46
42
Address string
47
43
48
44
// Client is used by the Client to drive HTTP requests. If not provided,
49
- // a new http.Client based on the provided RoundTripper (or DefaultRoundTripper) will be used.
50
- Client HttpClient
45
+ // a new one based on the provided RoundTripper (or DefaultRoundTripper) will be used.
46
+ Client * http. Client
51
47
52
48
// RoundTripper is used by the Client to drive HTTP requests. If not
53
49
// provided, DefaultRoundTripper will be used.
@@ -61,13 +57,13 @@ func (cfg *Config) roundTripper() http.RoundTripper {
61
57
return cfg .RoundTripper
62
58
}
63
59
64
- func (cfg * Config ) client () HttpClient {
60
+ func (cfg * Config ) client () http. Client {
65
61
if cfg .Client == nil {
66
- return & http.Client {
62
+ return http.Client {
67
63
Transport : cfg .roundTripper (),
68
64
}
69
65
}
70
- return cfg .Client
66
+ return * cfg .Client
71
67
}
72
68
73
69
func (cfg * Config ) validate () error {
@@ -105,7 +101,7 @@ func NewClient(cfg Config) (Client, error) {
105
101
106
102
type httpClient struct {
107
103
endpoint * url.URL
108
- client HttpClient
104
+ client http. Client
109
105
}
110
106
111
107
func (c * httpClient ) URL (ep string , args map [string ]string ) * url.URL {
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ func TestClientURL(t *testing.T) {
105
105
106
106
hclient := & httpClient {
107
107
endpoint : ep ,
108
- client : & http.Client {Transport : DefaultRoundTripper },
108
+ client : http.Client {Transport : DefaultRoundTripper },
109
109
}
110
110
111
111
u := hclient .URL (test .endpoint , test .args )
You can’t perform that action at this time.
0 commit comments