-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathmain.go
112 lines (92 loc) · 2.12 KB
/
main.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package HttpRequest
import (
"crypto/tls"
"net/http"
"net/url"
"time"
)
func NewRequest() *Request {
r := &Request{
timeout: 30,
headers: map[string]string{},
cookies: map[string]string{},
}
return r
}
// Debug model
func Debug(v bool) *Request {
r := NewRequest()
return r.Debug(v)
}
func Jar(v http.CookieJar) *Request {
r := NewRequest()
return r.Jar(v)
}
func DisableKeepAlives(v bool) *Request {
r := NewRequest()
return r.DisableKeepAlives(v)
}
func CheckRedirect(v func(req *http.Request, via []*http.Request) error) *Request {
r := NewRequest()
return r.CheckRedirect(v)
}
func TLSClient(v *tls.Config) *Request {
r := NewRequest()
return r.SetTLSClient(v)
}
func SetTLSClient(v *tls.Config) *Request {
r := NewRequest()
return r.SetTLSClient(v)
}
func SetHeaders(headers map[string]string) *Request {
r := NewRequest()
return r.SetHeaders(headers)
}
func SetCookies(cookies map[string]string) *Request {
r := NewRequest()
return r.SetCookies(cookies)
}
func SetBasicAuth(username, password string) *Request {
r := NewRequest()
return r.SetBasicAuth(username, password)
}
func JSON() *Request {
r := NewRequest()
return r.JSON()
}
func Proxy(v func(*http.Request) (*url.URL, error)) *Request {
r := NewRequest()
return r.Proxy(v)
}
func SetTimeout(d time.Duration) *Request {
r := NewRequest()
return r.SetTimeout(d)
}
func Transport(v *http.Transport) *Request {
r := NewRequest()
return r.Transport(v)
}
// Get is a get http request
func Get(url string, data ...interface{}) (*Response, error) {
r := NewRequest()
return r.Get(url, data...)
}
func Post(url string, data ...interface{}) (*Response, error) {
r := NewRequest()
return r.Post(url, data...)
}
// Put is a put http request
func Put(url string, data ...interface{}) (*Response, error) {
r := NewRequest()
return r.Put(url, data...)
}
// Delete is a delete http request
func Delete(url string, data ...interface{}) (*Response, error) {
r := NewRequest()
return r.Delete(url, data...)
}
// Upload file
func Upload(url, filename, fileinput string) (*Response, error) {
r := NewRequest()
return r.Upload(url, filename, fileinput)
}