-
Notifications
You must be signed in to change notification settings - Fork 3
/
base.go
67 lines (59 loc) · 2.43 KB
/
base.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 req implements a friendly API over Go's existing net/http library
package req
// Get takes 2 parameters and returns a Response Struct. These two options are:
// 1. A URL
// 2. A RqOptions struct
// If you do not intend to use the `RqOptions` you can just pass nil
func Get(url string, ro *RqOptions) (*Response, error) {
return DoRegularRequest(MethodGet, url, ro)
}
// Put takes 2 parameters and returns a Response struct. These two options are:
// 1. A URL
// 2. A RqOptions struct
// If you do not intend to use the `RqOptions` you can just pass nil
func Put(url string, ro *RqOptions) (*Response, error) {
return DoRegularRequest(MethodPut, url, ro)
}
// Patch takes 2 parameters and returns a Response struct. These two options are:
// 1. A URL
// 2. A RqOptions struct
// If you do not intend to use the `RqOptions` you can just pass nil
func Patch(url string, ro *RqOptions) (*Response, error) {
return DoRegularRequest(MethodPatch, url, ro)
}
// Delete takes 2 parameters and returns a Response struct. These two options are:
// 1. A URL
// 2. A RqOptions struct
// If you do not intend to use the `RqOptions` you can just pass nil
func Delete(url string, ro *RqOptions) (*Response, error) {
return DoRegularRequest(MethodDelete, url, ro)
}
// Post takes 2 parameters and returns a Response channel. These two options are:
// 1. A URL
// 2. A RqOptions struct
// If you do not intend to use the `RqOptions` you can just pass nil
func Post(url string, ro *RqOptions) (*Response, error) {
return DoRegularRequest(MethodPost, url, ro)
}
// Head takes 2 parameters and returns a Response channel. These two options are:
// 1. A URL
// 2. A RqOptions struct
// If you do not intend to use the `RqOptions` you can just pass nil
func Head(url string, ro *RqOptions) (*Response, error) {
return DoRegularRequest(MethodHead, url, ro)
}
// Options takes 2 parameters and returns a Response struct. These two options are:
// 1. A URL
// 2. A RqOptions struct
// If you do not intend to use the `RqOptions` you can just pass nil
func Options(url string, ro *RqOptions) (*Response, error) {
return DoRegularRequest(MethodOptions, url, ro)
}
// Req takes 3 parameters and returns a Response Struct. These three options are:
// 1. A verb
// 2. A URL
// 3. A RqOptions struct
// If you do not intend to use the `RqOptions` you can just pass nil
func Req(verb string, url string, ro *RqOptions) (*Response, error) {
return DoRegularRequest(verb, url, ro)
}