-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_options.go
47 lines (39 loc) · 992 Bytes
/
client_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
// AGPL License
// Copyright (c) 2023 ysicing <[email protected]>
package xuanim
type ClientOptionFunc func(*Client) error
// WithBaseURL sets the base URL for API requests to a custom endpoint.
func WithBaseURL(urlStr string) ClientOptionFunc {
return func(c *Client) error {
return c.setBaseURL(urlStr)
}
}
func WithDevMode() ClientOptionFunc {
return func(c *Client) error {
return c.setDebug()
}
}
func WithDumpAll() ClientOptionFunc {
return func(c *Client) error {
return c.setDumpAll()
}
}
// WithoutProxy 禁用代理, 默认情况下会读取HTTP_PROXY/HTTPS_PROXY/http_proxy/https_proxy变量
func WithoutProxy() ClientOptionFunc {
return func(c *Client) error {
return c.setDisableProxy()
}
}
func WithUserAgent(ua string) ClientOptionFunc {
return func(c *Client) error {
if ua == "" {
ua = userAgent
}
return c.setReqUserAgent(ua)
}
}
func WithCustom(custom bool) ClientOptionFunc {
return func(c *Client) error {
return c.setCustom(custom)
}
}