@@ -10,6 +10,7 @@ import (
10
10
"net/http"
11
11
"net/http/cookiejar"
12
12
"net/url"
13
+ "os"
13
14
"time"
14
15
15
16
"golang.org/x/net/publicsuffix"
@@ -39,7 +40,7 @@ func New() *Client {
39
40
Token : "" ,
40
41
Cookies : make ([]* http.Cookie , 0 ),
41
42
Debug : false ,
42
- Log : getLogger (nil ),
43
+ Log : getLogger (os . Stderr ),
43
44
httpClient : & http.Client {Jar : cookieJar },
44
45
transport : & http.Transport {},
45
46
}
@@ -72,122 +73,122 @@ func R() *Request {
72
73
return DefaultClient .R ()
73
74
}
74
75
75
- // SetHostURL sets Host URL. See Client.SetHostURL for more information.
76
+ // SetHostURL sets Host URL. See ` Client.SetHostURL for more information.
76
77
func SetHostURL (url string ) * Client {
77
78
return DefaultClient .SetHostURL (url )
78
79
}
79
80
80
- // SetHeader sets single header. See Client.SetHeader for more information.
81
+ // SetHeader sets single header. See ` Client.SetHeader` for more information.
81
82
func SetHeader (header , value string ) * Client {
82
83
return DefaultClient .SetHeader (header , value )
83
84
}
84
85
85
- // SetHeaders sets multiple headers. See Client.SetHeaders for more information.
86
+ // SetHeaders sets multiple headers. See ` Client.SetHeaders` for more information.
86
87
func SetHeaders (headers map [string ]string ) * Client {
87
88
return DefaultClient .SetHeaders (headers )
88
89
}
89
90
90
- // SetCookie sets single cookie object. See Client.SetCookie for more information.
91
+ // SetCookie sets single cookie object. See ` Client.SetCookie` for more information.
91
92
func SetCookie (hc * http.Cookie ) * Client {
92
93
return DefaultClient .SetCookie (hc )
93
94
}
94
95
95
- // SetCookies sets multiple cookie object. See Client.SetCookies for more information.
96
+ // SetCookies sets multiple cookie object. See ` Client.SetCookies` for more information.
96
97
func SetCookies (cs []* http.Cookie ) * Client {
97
98
return DefaultClient .SetCookies (cs )
98
99
}
99
100
100
- // SetQueryParam method sets single paramater and its value. See Client.SetQueryParam for more information.
101
+ // SetQueryParam method sets single paramater and its value. See ` Client.SetQueryParam` for more information.
101
102
func SetQueryParam (param , value string ) * Client {
102
103
return DefaultClient .SetQueryParam (param , value )
103
104
}
104
105
105
- // SetQueryParams method sets multiple paramaters and its value. See Client.SetQueryParams for more information.
106
+ // SetQueryParams method sets multiple paramaters and its value. See ` Client.SetQueryParams` for more information.
106
107
func SetQueryParams (params map [string ]string ) * Client {
107
108
return DefaultClient .SetQueryParams (params )
108
109
}
109
110
110
- // SetFormData method sets Form parameters and its values. See Client.SetFormData for more information.
111
+ // SetFormData method sets Form parameters and its values. See ` Client.SetFormData` for more information.
111
112
func SetFormData (data map [string ]string ) * Client {
112
113
return DefaultClient .SetFormData (data )
113
114
}
114
115
115
- // SetBasicAuth method sets the basic authentication header. See Client.SetBasicAuth for more information.
116
+ // SetBasicAuth method sets the basic authentication header. See ` Client.SetBasicAuth` for more information.
116
117
func SetBasicAuth (username , password string ) * Client {
117
118
return DefaultClient .SetBasicAuth (username , password )
118
119
}
119
120
120
- // SetAuthToken method sets bearer auth token header. See Client.SetAuthToken for more information.
121
+ // SetAuthToken method sets bearer auth token header. See ` Client.SetAuthToken` for more information.
121
122
func SetAuthToken (token string ) * Client {
122
123
return DefaultClient .SetAuthToken (token )
123
124
}
124
125
125
- // OnBeforeRequest method sets request middleware. See Client.OnBeforeRequest for more information.
126
+ // OnBeforeRequest method sets request middleware. See ` Client.OnBeforeRequest` for more information.
126
127
func OnBeforeRequest (m func (* Client , * Request ) error ) * Client {
127
128
return DefaultClient .OnBeforeRequest (m )
128
129
}
129
130
130
- // OnAfterResponse method sets response middleware. See Client.OnAfterResponse for more information.
131
+ // OnAfterResponse method sets response middleware. See ` Client.OnAfterResponse` for more information.
131
132
func OnAfterResponse (m func (* Client , * Response ) error ) * Client {
132
133
return DefaultClient .OnAfterResponse (m )
133
134
}
134
135
135
- // SetDebug method enables the debug mode. See Client.SetDebug for more information.
136
+ // SetDebug method enables the debug mode. See ` Client.SetDebug` for more information.
136
137
func SetDebug (d bool ) * Client {
137
138
return DefaultClient .SetDebug (d )
138
139
}
139
140
140
- // SetLogger method sets given writer for logging. See Client.SetLogger for more information.
141
+ // SetLogger method sets given writer for logging. See ` Client.SetLogger` for more information.
141
142
func SetLogger (w io.Writer ) * Client {
142
143
return DefaultClient .SetLogger (w )
143
144
}
144
145
145
- // SetContentLength method enables `Content-Length` value. See Client.SetContentLength for more information.
146
+ // SetContentLength method enables `Content-Length` value. See ` Client.SetContentLength` for more information.
146
147
func SetContentLength (l bool ) * Client {
147
148
return DefaultClient .SetContentLength (l )
148
149
}
149
150
150
- // SetError method is to register the global or client common `Error` object. See Client.SetError for more information.
151
+ // SetError method is to register the global or client common `Error` object. See ` Client.SetError` for more information.
151
152
func SetError (err interface {}) * Client {
152
153
return DefaultClient .SetError (err )
153
154
}
154
155
155
- // SetRedirectPolicy method sets the client redirect poilicy. See Client.SetRedirectPolicy for more information.
156
+ // SetRedirectPolicy method sets the client redirect poilicy. See ` Client.SetRedirectPolicy` for more information.
156
157
func SetRedirectPolicy (policies ... interface {}) * Client {
157
158
return DefaultClient .SetRedirectPolicy (policies ... )
158
159
}
159
160
160
- // SetHTTPMode method sets go-resty mode into HTTP. See Client.SetMode for more information.
161
+ // SetHTTPMode method sets go-resty mode into HTTP. See ` Client.SetMode` for more information.
161
162
func SetHTTPMode () * Client {
162
163
return DefaultClient .SetHTTPMode ()
163
164
}
164
165
165
- // SetRESTMode method sets go-resty mode into RESTful. See Client.SetMode for more information.
166
+ // SetRESTMode method sets go-resty mode into RESTful. See ` Client.SetMode` for more information.
166
167
func SetRESTMode () * Client {
167
168
return DefaultClient .SetRESTMode ()
168
169
}
169
170
170
- // Mode method returns the current client mode. See Client.Mode for more information.
171
+ // Mode method returns the current client mode. See ` Client.Mode` for more information.
171
172
func Mode () string {
172
173
return DefaultClient .Mode ()
173
174
}
174
175
175
- // SetTLSClientConfig method sets TLSClientConfig for underling client Transport. See Client.SetTLSClientConfig for more information.
176
+ // SetTLSClientConfig method sets TLSClientConfig for underling client Transport. See ` Client.SetTLSClientConfig` for more information.
176
177
func SetTLSClientConfig (config * tls.Config ) * Client {
177
178
return DefaultClient .SetTLSClientConfig (config )
178
179
}
179
180
180
- // SetTimeout method sets timeout for request. See Client.SetTimeout for more information.
181
+ // SetTimeout method sets timeout for request. See ` Client.SetTimeout` for more information.
181
182
func SetTimeout (timeout time.Duration ) * Client {
182
183
return DefaultClient .SetTimeout (timeout )
183
184
}
184
185
185
- // SetProxy method sets Proxy for request. See Client.SetProxy for more information.
186
+ // SetProxy method sets Proxy for request. See ` Client.SetProxy` for more information.
186
187
func SetProxy (proxyURL string ) * Client {
187
188
return DefaultClient .SetProxy (proxyURL )
188
189
}
189
190
190
- // RemoveProxy method removes the proxy configuration. See Client.RemoveProxy for more information.
191
+ // RemoveProxy method removes the proxy configuration. See ` Client.RemoveProxy` for more information.
191
192
func RemoveProxy () * Client {
192
193
return DefaultClient .RemoveProxy ()
193
194
}
0 commit comments