-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.go
67 lines (59 loc) · 2.34 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
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
package gotiktoklive
type TikTokLiveOption func(t *TikTok) error
// SigningApiKey sets the singer API key.
func SigningApiKey(apiKey string) TikTokLiveOption {
return func(t *TikTok) error {
t.apiKey = apiKey
return nil
}
}
// SigningUrl defines the signer. The default is https://tiktok.eulerstream.com. Supports any signer that supports the
// signing api as defined by https://www.eulerstream.com/docs/openapi
func SigningUrl(url string) TikTokLiveOption {
return func(t *TikTok) error {
t.signerUrl = url
return nil
}
}
// DisableSigningLimitsValidation will disable querying the signer for limits and using those as the reasonable limits
// for signing requests per second. Instead, this library will be limited to signing only 5 signing requests per minute
// and may limit functionality compared to the request limit the signer provides.
func DisableSigningLimitsValidation(t *TikTok) error {
t.getLimits = false
return nil
}
// EnableExperimentalEvents enables experimental events that have not been figured out yet and the API for them is not
// stable. It may also induce additional logging that might be undesirable.
func EnableExperimentalEvents(t *TikTok) error {
t.enableExperimentalEvents = true
return nil
}
// EnableExtraWebCastDebug an unreasonable amount of debug for library development and troubleshooting. This option
// makes no guarantee of ever having the same output and is only for development and triage purposes.
func EnableExtraWebCastDebug(t *TikTok) error {
t.enableExtraDebug = true
return nil
}
// EnableWSTrace will put traces for all websocket messages into the given file. The file will be overwritten so
// if you want multiple traces make sure handle giving a unique filename each startup.
func EnableWSTrace(file string) TikTokLiveOption {
return func(t *TikTok) error {
t.enableWSTrace = true
t.wsTraceFile = file
t.wsTraceChan = make(chan struct{ direction, hex string }, 50)
return nil
}
}
// Proxy will set a proxy for both the http client and the websocket. You can
// manually set a proxy with option or by using the HTTPS_PROXY environment variable.
// ALL_PROXY can be used to set a proxy only for the websocket.
func Proxy(url string, insecure bool) TikTokLiveOption {
if url == "" {
return func(t *TikTok) error {
return nil
}
}
return func(t *TikTok) error {
return t.setProxy(url, insecure)
}
}