-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
41 lines (35 loc) · 964 Bytes
/
option.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
package mono
type optioner interface {
setDomain(string)
setClient(HTTPClient)
setUnmarshaller(Unmarshaller)
setWebhookBufferSize(uint32)
}
// Option allows to change default values for client.
type Option func(optioner)
// WithDomain allows to change the default API domain.
// The domain should be in format `scheme://domain`
func WithDomain(domain string) Option {
return func(o optioner) {
o.setDomain(domain)
}
}
// WithClient allows to change default http.Client
func WithClient(client HTTPClient) Option {
return func(o optioner) {
o.setClient(client)
}
}
// WithUnmarshaller allows to change default `json.Unmarshal` to something else.
func WithUnmarshaller(u Unmarshaller) Option {
return func(o optioner) {
o.setUnmarshaller(u)
}
}
// WithWebhookBufferSize allows to change default buffer size.
// Default value is 100.
func WithWebhookBufferSize(size uint32) Option {
return func(o optioner) {
o.setWebhookBufferSize(size)
}
}