-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoption.go
More file actions
40 lines (33 loc) · 785 Bytes
/
option.go
File metadata and controls
40 lines (33 loc) · 785 Bytes
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
// Copyright 2018 Blockchain-CN . All rights reserved.
// https://github.com/Blockchain-CN
package httpsvr
import "time"
type option struct {
maxAccess int
dumpResponse bool
enableElasped bool
dumpAccess bool
validate bool
readTimeout time.Duration
writeTimeout time.Duration
}
// ServerOption option赋值回调函数
type ServerOption func(o *option)
// SetReadTimeout 设置读超时
func SetReadTimeout(rt time.Duration) ServerOption {
return func(o *option) {
o.readTimeout = rt
}
}
// SetWriteTimeout 设置写超时
func SetWriteTimeout(wt time.Duration) ServerOption {
return func(o *option) {
o.writeTimeout = wt
}
}
// SetMaxAccess 最大接入数
func SetMaxAccess(i int) ServerOption {
return func(o *option) {
o.maxAccess = i
}
}