-
Notifications
You must be signed in to change notification settings - Fork 23
/
options.go
57 lines (50 loc) · 911 Bytes
/
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
52
53
54
55
56
57
package customerio
import "net/http"
type option struct {
api func(*APIClient)
track func(*CustomerIO)
}
type region struct {
ApiURL string
TrackURL string
}
var (
RegionUS = region{
ApiURL: "https://api.customer.io",
TrackURL: "https://track.customer.io",
}
RegionEU = region{
ApiURL: "https://api-eu.customer.io",
TrackURL: "https://track-eu.customer.io",
}
)
func WithRegion(r region) option {
return option{
api: func(a *APIClient) {
a.URL = r.ApiURL
},
track: func(c *CustomerIO) {
c.URL = r.TrackURL
},
}
}
func WithHTTPClient(client *http.Client) option {
return option{
api: func(a *APIClient) {
a.Client = client
},
track: func(c *CustomerIO) {
c.Client = client
},
}
}
func WithUserAgent(ua string) option {
return option{
api: func(a *APIClient) {
a.UserAgent = ua
},
track: func(c *CustomerIO) {
c.UserAgent = ua
},
}
}