-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
44 lines (36 loc) · 965 Bytes
/
config.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
package gate
import "net/http"
type (
// Config provides service configuration for service.
Config struct {
// The HTTP client to use when sending requests.
HTTPClient *http.Client
ID string
AccessToken string
}
)
var (
defaultConfig = *(NewConfig().WithHTTPClient(http.DefaultClient))
)
// NewConfig returns a pointer of new Config objects.
func NewConfig() *Config {
return &Config{}
}
// WithHTTPClient sets a config HTTPClient value returning a Config pointer
// for chaining.
func (c *Config) WithHTTPClient(client *http.Client) *Config {
c.HTTPClient = client
return c
}
// WithID sets an id value to verify service returning
// a Config pointer for chaining.
func (c *Config) WithID(id string) *Config {
c.ID = id
return c
}
// WithAccessToken sets a access token value to verify service returning
// a Config pointer for chaining.
func (c *Config) WithAccessToken(token string) *Config {
c.AccessToken = token
return c
}