forked from ListenNotes/podcast-api-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
23 lines (19 loc) · 801 Bytes
/
options.go
File metadata and controls
23 lines (19 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package listennotes
import (
"net/http"
)
// ClientOption allows for options to be passed to the client constructor function
type ClientOption func(c *standardHTTPClient)
// WithHTTPClient allows providing an underlying http client. It is good practice to _not_ use the default http client
// that Go provides as it has no timeouts. If you do not provide your own default client, a reasonable one will be created for you.
func WithHTTPClient(httpClient *http.Client) ClientOption {
return func(c *standardHTTPClient) {
c.httpClient = httpClient
}
}
// WithBaseURL allows for providing a custom base URL. If not provided a reasonable url will be selected based on your apiKey.
func WithBaseURL(baseURL string) ClientOption {
return func(c *standardHTTPClient) {
c.baseURL = baseURL
}
}