-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoption.go
77 lines (62 loc) · 1.23 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package wopan
import (
"net/http"
"github.com/go-resty/resty/v2"
)
type Option func(w *WoClient)
func WithAccessToken(token string) Option {
return func(w *WoClient) {
w.SetAccessToken(token)
}
}
func WithRefreshToken(token string) Option {
return func(w *WoClient) {
w.SetRefreshToken(token)
}
}
func WithPsToken(psToken string) Option {
return func(w *WoClient) {
w.SetPsToken(psToken)
}
}
func WithUA(ua string) Option {
return func(w *WoClient) {
w.SetUA(ua)
}
}
func WithJsonMarshalFunc(f func(v interface{}) ([]byte, error)) Option {
return func(w *WoClient) {
w.SetJsonMarshalFunc(f)
}
}
func WithJsonUnmarshalFunc(f func(data []byte, v interface{}) error) Option {
return func(w *WoClient) {
w.SetJsonUnmarshalFunc(f)
}
}
func WithClient(hc *http.Client) Option {
return func(c *WoClient) {
c.SetHttpClient(hc)
}
}
func WithRestyClient(rc *resty.Client) Option {
return func(c *WoClient) {
c.client = rc
}
}
func WithDebug() Option {
return func(c *WoClient) {
c.SetDebug(true)
}
}
func WithTrace() Option {
return func(c *WoClient) {
c.EnableTrace()
}
}
func WithProxy(proxy string) Option {
return func(c *WoClient) {
c.SetProxy(proxy)
}
}
type RestyOption func(request *resty.Request)