-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathoptions.go
49 lines (40 loc) · 940 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
package postmark
import "net/http"
// Option to set an optional client value.
type Option func(o *Options)
// Options for our client.
type Options struct {
Client *http.Client
BackendURL string
UserAgent string
}
// NewOptions returns a new Options with defaults and supplied overrides.
func NewOptions(opts ...Option) *Options {
out := Options{
Client: http.DefaultClient,
BackendURL: backendURL,
UserAgent: userAgent,
}
for _, o := range opts {
o(&out)
}
return &out
}
// WithClient allows you to set a custom http client.
func WithClient(v *http.Client) Option {
return func(o *Options) {
o.Client = v
}
}
// WithBackendURL allows you to set a custom backend URL.
func WithBackendURL(v string) Option {
return func(o *Options) {
o.BackendURL = v
}
}
// WithUserAgent allows you to set a custom user agent.
func WithUserAgent(v string) Option {
return func(o *Options) {
o.UserAgent = v
}
}