forked from simplesurance/bunny-go
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopts.go
More file actions
45 lines (37 loc) · 1.1 KB
/
opts.go
File metadata and controls
45 lines (37 loc) · 1.1 KB
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
package bunny
import "net/http"
// Option is a type for Client options.
type Option func(*Client)
// WithHTTPRequestLogger is an option to log all sent out HTTP-Request via a log function.
func WithHTTPRequestLogger(logger Logf) Option {
return func(clt *Client) {
clt.httpRequestLogf = logger
}
}
// WithHTTPResponseLogger is an option to log all received HTTP-Responses via a log function.
func WithHTTPResponseLogger(logger Logf) Option {
return func(clt *Client) {
clt.httpResponseLogf = logger
}
}
// WithUserAgent is an option to specify the value of the User-Agent HTTP Header.
func WithUserAgent(userAgent string) Option {
return func(clt *Client) {
clt.userAgent = userAgent
}
}
// WithLogger is an option to set a log function to which informal and warning messages will be logged.
func WithLogger(logger Logf) Option {
return func(clt *Client) {
clt.logf = logger
}
}
// WithHTTPClient is an option to set the http.Client used by the bunny client.
func WithHTTPClient(client *http.Client) Option {
return func(clt *Client) {
if client == nil {
return
}
clt.httpClient = client
}
}