-
Notifications
You must be signed in to change notification settings - Fork 6
/
options.go
51 lines (43 loc) · 1.35 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2021-present Airheart, Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
package duffel
import "net/http"
// WithAPIToken sets the API host to the default Duffel production host.
func WithDefaultAPI() Option {
return func(c *Options) {
c.Host = "https://api.duffel.com"
}
}
// WithHost allows you to specify the Duffel API host to use for making requests.
func WithHost(host string) Option {
return func(c *Options) {
c.Host = host
}
}
// WithVersion allows you to specify "Duffel-Version" header for the API version that you are targeting.
func WithAPIVersion(version string) Option {
return func(c *Options) {
c.Version = version
}
}
// WithUserAgent allows you to specify a custom user agent string to use for making requests.
func WithUserAgent(ua string) Option {
return func(c *Options) {
c.UserAgent = ua
}
}
// WithHTTPClient allows you to specify a custom http.Client to use for making requests.
// This is useful if you want to use a custom transport or proxy.
func WithHTTPClient(client *http.Client) Option {
return func(c *Options) {
c.HttpDoer = client
}
}
// WithDebug enables debug logging of requests and responses.
// DO NOT USE IN PRODUCTION.
func WithDebug() Option {
return func(c *Options) {
c.Debug = true
}
}