-
Notifications
You must be signed in to change notification settings - Fork 0
/
methods.go
138 lines (110 loc) · 5.26 KB
/
methods.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package qst
import "net/http"
// NewGet builds a new *http.Request with method GET.
func NewGet(url string, options ...Option) (*http.Request, error) {
return New(http.MethodGet, url, options...)
}
// Get makes a GET request using the current DefaultClient and returns the *http.Response.
func Get(url string, options ...Option) (*http.Response, error) {
return Do(http.MethodGet, url, options...)
}
// Get makes a GET request and returns the *http.Response using the Doer assigned to c.
func (c *Client) Get(options ...Option) (*http.Response, error) {
return c.Do(http.MethodGet, options...)
}
// NewHead builds a new *http.Request with method HEAD.
func NewHead(url string, options ...Option) (*http.Request, error) {
return New(http.MethodHead, url, options...)
}
// Head makes a HEAD request using the current DefaultClient and returns the *http.Response.
func Head(url string, options ...Option) (*http.Response, error) {
return Do(http.MethodHead, url, options...)
}
// Head makes a HEAD request and returns the *http.Response using the Doer assigned to c.
func (c *Client) Head(options ...Option) (*http.Response, error) {
return c.Do(http.MethodHead, options...)
}
// NewPost builds a new *http.Request with method POST.
func NewPost(url string, options ...Option) (*http.Request, error) {
return New(http.MethodPost, url, options...)
}
// Post makes a POST request using the current DefaultClient and returns the *http.Response.
func Post(url string, options ...Option) (*http.Response, error) {
return Do(http.MethodPost, url, options...)
}
// Post makes a POST request and returns the *http.Response using the Doer assigned to c.
func (c *Client) Post(options ...Option) (*http.Response, error) {
return c.Do(http.MethodPost, options...)
}
// NewPut builds a new *http.Request with method PUT.
func NewPut(url string, options ...Option) (*http.Request, error) {
return New(http.MethodPut, url, options...)
}
// Put makes a PUT request using the current DefaultClient and returns the *http.Response.
func Put(url string, options ...Option) (*http.Response, error) {
return Do(http.MethodPut, url, options...)
}
// Put makes a PUT request and returns the *http.Response using the Doer assigned to c.
func (c *Client) Put(options ...Option) (*http.Response, error) {
return c.Do(http.MethodPut, options...)
}
// NewPatch builds a new *http.Request with method PATCH.
func NewPatch(url string, options ...Option) (*http.Request, error) {
return New(http.MethodPatch, url, options...)
}
// Patch makes a PATCH request using the current DefaultClient and returns the *http.Response.
func Patch(url string, options ...Option) (*http.Response, error) {
return Do(http.MethodPatch, url, options...)
}
// Patch makes a PATCH request and returns the *http.Response using the Doer assigned to c.
func (c *Client) Patch(options ...Option) (*http.Response, error) {
return c.Do(http.MethodPatch, options...)
}
// NewDelete builds a new *http.Request with method DELETE.
func NewDelete(url string, options ...Option) (*http.Request, error) {
return New(http.MethodDelete, url, options...)
}
// Delete makes a DELETE request using the current DefaultClient and returns the *http.Response.
func Delete(url string, options ...Option) (*http.Response, error) {
return Do(http.MethodDelete, url, options...)
}
// Delete makes a DELETE request and returns the *http.Response using the Doer assigned to c.
func (c *Client) Delete(options ...Option) (*http.Response, error) {
return c.Do(http.MethodDelete, options...)
}
// NewConnect builds a new *http.Request with method CONNECT.
func NewConnect(url string, options ...Option) (*http.Request, error) {
return New(http.MethodConnect, url, options...)
}
// Connect makes a CONNECT request using the current DefaultClient and returns the *http.Response.
func Connect(url string, options ...Option) (*http.Response, error) {
return Do(http.MethodConnect, url, options...)
}
// Connect makes a CONNECT request and returns the *http.Response using the Doer assigned to c.
func (c *Client) Connect(options ...Option) (*http.Response, error) {
return c.Do(http.MethodConnect, options...)
}
// NewOptions builds a new *http.Request with method OPTIONS.
func NewOptions(url string, options ...Option) (*http.Request, error) {
return New(http.MethodOptions, url, options...)
}
// Options makes a OPTIONS request using the current DefaultClient and returns the *http.Response.
func Options(url string, options ...Option) (*http.Response, error) {
return Do(http.MethodOptions, url, options...)
}
// Options makes a OPTIONS request and returns the *http.Response using the Doer assigned to c.
func (c *Client) Options(options ...Option) (*http.Response, error) {
return c.Do(http.MethodOptions, options...)
}
// NewTrace builds a new *http.Request with method TRACE.
func NewTrace(url string, options ...Option) (*http.Request, error) {
return New(http.MethodTrace, url, options...)
}
// Trace makes a TRACE request using the current DefaultClient and returns the *http.Response.
func Trace(url string, options ...Option) (*http.Response, error) {
return Do(http.MethodTrace, url, options...)
}
// Trace makes a TRACE request and returns the *http.Response using the Doer assigned to c.
func (c *Client) Trace(options ...Option) (*http.Response, error) {
return c.Do(http.MethodTrace, options...)
}