-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
40 lines (34 loc) · 1.03 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
package peopledatalabs_go
import (
"net/http"
"time"
"github.com/peopledatalabs/peopledatalabs-go/v3/api"
"github.com/peopledatalabs/peopledatalabs-go/v3/logger"
)
// WithHTTPClient sets a custom HTTP Client
// that will be used to make API requests for the library
func WithHTTPClient(httpCli *http.Client) api.ClientOptions {
return func(client *api.Client) {
client.HttpClient = httpCli
}
}
// WithTimeout sets the timeout the API client uses
// Default timeout is api.DefaultTimeout
func WithTimeout(timeout time.Duration) api.ClientOptions {
return func(client *api.Client) {
client.HttpClient.Timeout = timeout
}
}
// WithLogger sets a custom logger for the library
func WithLogger(logger logger.Logger) api.ClientOptions {
return func(client *api.Client) {
client.Logger = logger
}
}
// WithLogLevel sets the level at which the library will log
// Default behaviour is to log at logger.DefaultLevel
func WithLogLevel(level logger.Level) api.ClientOptions {
return func(client *api.Client) {
client.Logger.SetLevel(level)
}
}