-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgorilla_upgrader_options.go
41 lines (37 loc) · 1.15 KB
/
gorilla_upgrader_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
package wspubsub
import (
"net/http"
"time"
)
// GorillaConnectionUpgraderOptions represents configuration of the GorillaConnectionUpgrader.
type GorillaConnectionUpgraderOptions struct {
MaxMessageSize int64
ReadTimout time.Duration
WriteTimout time.Duration
HandshakeTimeout time.Duration
ReadBufferSize int
WriteBufferSize int
Subprotocols []string
Error func(w http.ResponseWriter, r *http.Request, status int, reason error)
CheckOrigin func(r *http.Request) bool
EnableCompression bool
IsDebug bool
DebugFuncTimeLimit time.Duration
}
// NewGorillaConnectionUpgraderOptions initializes a new GorillaConnectionUpgraderOptions.
// nolint: gomnd
func NewGorillaConnectionUpgraderOptions() GorillaConnectionUpgraderOptions {
options := GorillaConnectionUpgraderOptions{
MaxMessageSize: 1 * 1024 * 1024,
ReadTimout: 60 * time.Second,
WriteTimout: 10 * time.Second,
ReadBufferSize: 4096,
WriteBufferSize: 4096,
CheckOrigin: func(r *http.Request) bool {
return true
},
IsDebug: false,
DebugFuncTimeLimit: 1 * time.Millisecond,
}
return options
}