-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.go
67 lines (55 loc) · 1.15 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 fasthttp
type (
Mapper map[string]string
RequestParams struct{ Mapper }
RequestHeaders struct{ Mapper }
RequestCookies struct{ Mapper }
RequestFiles struct{ Mapper }
)
func NewParams() Mapper {
return make(map[string]string)
}
func NewHeaders() Mapper {
return make(map[string]string)
}
func NewCookies() Mapper {
return make(map[string]string)
}
func NewFiles() Mapper {
return make(map[string]string)
}
func (m Mapper) Get(key string) string {
value, ok := m[key]
if ok {
return value
}
return ""
}
func (m Mapper) Set(key, value string) Mapper {
m[key] = value
return m
}
func newRequestOptions() *requestOptions {
return &requestOptions{
files: RequestFiles{Mapper: NewFiles()},
headers: requestHeaders{
normal: RequestHeaders{Mapper: NewHeaders()},
cookies: RequestCookies{Mapper: NewCookies()},
},
params: RequestParams{Mapper: NewParams()},
}
}
type requestOptions struct {
body []byte
Proxy string
files RequestFiles
headers requestHeaders
params RequestParams
}
type requestHeaders struct {
normal RequestHeaders
cookies RequestCookies
}
type RequestOption struct {
f func(*requestOptions)
}