-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsetting.go
More file actions
43 lines (35 loc) · 743 Bytes
/
setting.go
File metadata and controls
43 lines (35 loc) · 743 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
41
42
43
package ghttp
import (
"net/http"
"time"
)
// headerElements
type headerElements struct {
key string
value string
}
// SetConnectTimeout
func SetConnectTimeout(duration time.Duration) {
DefaultDialer.Timeout = duration
}
// AddHeader
func (r *Request) AddHeader(key string, value string) {
if r.headers == nil {
r.headers = []headerElements{}
}
r.headers = append(r.headers, headerElements{key: key, value: value})
}
// WithHeader
func (r Request) WithHeader(key string, value string) Request {
r.AddHeader(key, value)
return r
}
// AddCookie
func (r *Request) AddCookie(c *http.Cookie) {
r.cookies = append(r.cookies, c)
}
// WithCookie
func (r Request) WithCookie(c *http.Cookie) Request {
r.AddCookie(c)
return r
}