/
ghttp_client_api.go
127 lines (96 loc) · 3.53 KB
/
ghttp_client_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
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
// Copyright 2017 gf Author(https://github.com/snail007/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/snail007/gf.
package ghttp
func Get(url string) (*ClientResponse, error) {
return DoRequest("GET", url)
}
func Put(url string, data ...interface{}) (*ClientResponse, error) {
return DoRequest("PUT", url, data...)
}
func Post(url string, data ...interface{}) (*ClientResponse, error) {
return DoRequest("POST", url, data...)
}
func Delete(url string, data ...interface{}) (*ClientResponse, error) {
return DoRequest("DELETE", url, data...)
}
func Head(url string, data ...interface{}) (*ClientResponse, error) {
return DoRequest("HEAD", url, data...)
}
func Patch(url string, data ...interface{}) (*ClientResponse, error) {
return DoRequest("PATCH", url, data...)
}
func Connect(url string, data ...interface{}) (*ClientResponse, error) {
return DoRequest("CONNECT", url, data...)
}
func Options(url string, data ...interface{}) (*ClientResponse, error) {
return DoRequest("OPTIONS", url, data...)
}
func Trace(url string, data ...interface{}) (*ClientResponse, error) {
return DoRequest("TRACE", url, data...)
}
func DoRequest(method, url string, data ...interface{}) (*ClientResponse, error) {
return NewClient().DoRequest(method, url, data...)
}
func GetContent(url string, data ...interface{}) string {
return RequestContent("GET", url, data...)
}
func PutContent(url string, data ...interface{}) string {
return RequestContent("PUT", url, data...)
}
func PostContent(url string, data ...interface{}) string {
return RequestContent("POST", url, data...)
}
func DeleteContent(url string, data ...interface{}) string {
return RequestContent("DELETE", url, data...)
}
func HeadContent(url string, data ...interface{}) string {
return RequestContent("HEAD", url, data...)
}
func PatchContent(url string, data ...interface{}) string {
return RequestContent("PATCH", url, data...)
}
func ConnectContent(url string, data ...interface{}) string {
return RequestContent("CONNECT", url, data...)
}
func OptionsContent(url string, data ...interface{}) string {
return RequestContent("OPTIONS", url, data...)
}
func TraceContent(url string, data ...interface{}) string {
return RequestContent("TRACE", url, data...)
}
func RequestContent(method string, url string, data ...interface{}) string {
return NewClient().RequestContent(method, url, data...)
}
func GetBytes(url string, data ...interface{}) []byte {
return RequestBytes("GET", url, data...)
}
func PutBytes(url string, data ...interface{}) []byte {
return RequestBytes("PUT", url, data...)
}
func PostBytes(url string, data ...interface{}) []byte {
return RequestBytes("POST", url, data...)
}
func DeleteBytes(url string, data ...interface{}) []byte {
return RequestBytes("DELETE", url, data...)
}
func HeadBytes(url string, data ...interface{}) []byte {
return RequestBytes("HEAD", url, data...)
}
func PatchBytes(url string, data ...interface{}) []byte {
return RequestBytes("PATCH", url, data...)
}
func ConnectBytes(url string, data ...interface{}) []byte {
return RequestBytes("CONNECT", url, data...)
}
func OptionsBytes(url string, data ...interface{}) []byte {
return RequestBytes("OPTIONS", url, data...)
}
func TraceBytes(url string, data ...interface{}) []byte {
return RequestBytes("TRACE", url, data...)
}
func RequestBytes(method string, url string, data ...interface{}) []byte {
return NewClient().RequestBytes(method, url, data...)
}