forked from guonaihong/gout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setting.go
53 lines (42 loc) · 901 Bytes
/
setting.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
package setting
import (
"time"
"github.com/xishengcai/gout/debug"
)
// 设置
type Setting struct {
// debug相关字段
debug.Options
// 控制是否使用空值
NotIgnoreEmpty bool
//是否自动加ContentType
NoAutoContentType bool
//超时时间
Timeout time.Duration
// 目前用作SetTimeout 和 WithContext是互斥
// index是自增id,主要给互斥API定优先级
// 对于互斥api,后面的会覆盖前面的
Index int
//当前time 的index
TimeoutIndex int
UseChunked bool
}
// 使用chunked数据
func (s *Setting) Chunked() {
s.UseChunked = true
}
func (s *Setting) SetTimeout(d time.Duration) {
s.Index++
s.TimeoutIndex = s.Index
s.Timeout = d
}
func (s *Setting) SetDebug(b bool) {
s.Debug = b
}
func (s *Setting) Reset() {
s.NotIgnoreEmpty = false
s.NoAutoContentType = false
s.Index = 0
//s.TimeoutIndex = 0
s.Timeout = time.Duration(0)
}