forked from wangluozhe/requests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.go
49 lines (38 loc) · 1.36 KB
/
api.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
package requests
import (
"github.com/760644586/requests/models"
"github.com/760644586/requests/url"
"net/http"
)
func Request(method, rawurl string, req *url.Request) (*models.Response, error) {
session := NewSession()
return session.Request(method, rawurl, req)
}
func Get(rawurl string, req *url.Request) (*models.Response, error) {
return Request(http.MethodGet, rawurl, req)
}
func Post(rawurl string, req *url.Request) (*models.Response, error) {
return Request(http.MethodPost, rawurl, req)
}
func Options(rawurl string, req *url.Request) (*models.Response, error) {
return Request(http.MethodOptions, rawurl, req)
}
func Head(rawurl string, req *url.Request) (*models.Response, error) {
req.AllowRedirects = false
return Request(http.MethodHead, rawurl, req)
}
func Put(rawurl string, req *url.Request) (*models.Response, error) {
return Request(http.MethodPut, rawurl, req)
}
func Patch(rawurl string, req *url.Request) (*models.Response, error) {
return Request(http.MethodPatch, rawurl, req)
}
func Delete(rawurl string, req *url.Request) (*models.Response, error) {
return Request(http.MethodDelete, rawurl, req)
}
func Connect(rawurl string, req *url.Request) (*models.Response, error) {
return Request(http.MethodConnect, rawurl, req)
}
func Trace(rawurl string, req *url.Request) (*models.Response, error) {
return Request(http.MethodTrace, rawurl, req)
}