Browse code

Move deprecated client constructors to a separate file

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2019/01/21 23:01:48
Showing 2 changed files
... ...
@@ -100,14 +100,6 @@ func CheckRedirect(req *http.Request, via []*http.Request) error {
100 100
 	return ErrRedirect
101 101
 }
102 102
 
103
-// NewEnvClient initializes a new API client based on environment variables.
104
-// See FromEnv for a list of support environment variables.
105
-//
106
-// Deprecated: use NewClientWithOpts(FromEnv)
107
-func NewEnvClient() (*Client, error) {
108
-	return NewClientWithOpts(FromEnv)
109
-}
110
-
111 103
 // NewClientWithOpts initializes a new API client with default values. It takes functors
112 104
 // to modify values when creating it, like `NewClientWithOpts(WithVersion(…))`
113 105
 // It also initializes the custom http headers to add to each request.
... ...
@@ -167,18 +159,6 @@ func defaultHTTPClient(host string) (*http.Client, error) {
167 167
 	}, nil
168 168
 }
169 169
 
170
-// NewClient initializes a new API client for the given host and API version.
171
-// It uses the given http client as transport.
172
-// It also initializes the custom http headers to add to each request.
173
-//
174
-// It won't send any version information if the version number is empty. It is
175
-// highly recommended that you set a version or your client may break if the
176
-// server is upgraded.
177
-// Deprecated: use NewClientWithOpts
178
-func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) {
179
-	return NewClientWithOpts(WithHost(host), WithVersion(version), WithHTTPClient(client), WithHTTPHeaders(httpHeaders))
180
-}
181
-
182 170
 // Close the transport used by the client
183 171
 func (cli *Client) Close() error {
184 172
 	if t, ok := cli.client.Transport.(*http.Transport); ok {
185 173
new file mode 100644
... ...
@@ -0,0 +1,23 @@
0
+package client
1
+
2
+import "net/http"
3
+
4
+// NewClient initializes a new API client for the given host and API version.
5
+// It uses the given http client as transport.
6
+// It also initializes the custom http headers to add to each request.
7
+//
8
+// It won't send any version information if the version number is empty. It is
9
+// highly recommended that you set a version or your client may break if the
10
+// server is upgraded.
11
+// Deprecated: use NewClientWithOpts
12
+func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) {
13
+	return NewClientWithOpts(WithHost(host), WithVersion(version), WithHTTPClient(client), WithHTTPHeaders(httpHeaders))
14
+}
15
+
16
+// NewEnvClient initializes a new API client based on environment variables.
17
+// See FromEnv for a list of support environment variables.
18
+//
19
+// Deprecated: use NewClientWithOpts(FromEnv)
20
+func NewEnvClient() (*Client, error) {
21
+	return NewClientWithOpts(FromEnv)
22
+}