-
Notifications
You must be signed in to change notification settings - Fork 349
/
request_wrapper.go
529 lines (442 loc) · 20.3 KB
/
request_wrapper.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
package req
import (
"context"
"io"
"net/http"
"net/url"
"time"
)
// SetURL is a global wrapper methods which delegated
// to the default client, create a request and SetURL for request.
func SetURL(url string) *Request {
return defaultClient.R().SetURL(url)
}
// SetFormDataFromValues is a global wrapper methods which delegated
// to the default client, create a request and SetFormDataFromValues for request.
func SetFormDataFromValues(data url.Values) *Request {
return defaultClient.R().SetFormDataFromValues(data)
}
// SetFormData is a global wrapper methods which delegated
// to the default client, create a request and SetFormData for request.
func SetFormData(data map[string]string) *Request {
return defaultClient.R().SetFormData(data)
}
// SetOrderedFormData is a global wrapper methods which delegated
// to the default client, create a request and SetOrderedFormData for request.
func SetOrderedFormData(kvs ...string) *Request {
return defaultClient.R().SetOrderedFormData(kvs...)
}
// SetFormDataAnyType is a global wrapper methods which delegated
// to the default client, create a request and SetFormDataAnyType for request.
func SetFormDataAnyType(data map[string]interface{}) *Request {
return defaultClient.R().SetFormDataAnyType(data)
}
// SetCookies is a global wrapper methods which delegated
// to the default client, create a request and SetCookies for request.
func SetCookies(cookies ...*http.Cookie) *Request {
return defaultClient.R().SetCookies(cookies...)
}
// SetQueryString is a global wrapper methods which delegated
// to the default client, create a request and SetQueryString for request.
func SetQueryString(query string) *Request {
return defaultClient.R().SetQueryString(query)
}
// SetFileReader is a global wrapper methods which delegated
// to the default client, create a request and SetFileReader for request.
func SetFileReader(paramName, filePath string, reader io.Reader) *Request {
return defaultClient.R().SetFileReader(paramName, filePath, reader)
}
// SetFileBytes is a global wrapper methods which delegated
// to the default client, create a request and SetFileBytes for request.
func SetFileBytes(paramName, filename string, content []byte) *Request {
return defaultClient.R().SetFileBytes(paramName, filename, content)
}
// SetFiles is a global wrapper methods which delegated
// to the default client, create a request and SetFiles for request.
func SetFiles(files map[string]string) *Request {
return defaultClient.R().SetFiles(files)
}
// SetFile is a global wrapper methods which delegated
// to the default client, create a request and SetFile for request.
func SetFile(paramName, filePath string) *Request {
return defaultClient.R().SetFile(paramName, filePath)
}
// SetFileUpload is a global wrapper methods which delegated
// to the default client, create a request and SetFileUpload for request.
func SetFileUpload(f ...FileUpload) *Request {
return defaultClient.R().SetFileUpload(f...)
}
// SetResult is a global wrapper methods which delegated
// to the default client, create a request and SetSuccessResult for request.
//
// Deprecated: Use SetSuccessResult instead.
func SetResult(result interface{}) *Request {
return defaultClient.R().SetSuccessResult(result)
}
// SetSuccessResult is a global wrapper methods which delegated
// to the default client, create a request and SetSuccessResult for request.
func SetSuccessResult(result interface{}) *Request {
return defaultClient.R().SetSuccessResult(result)
}
// SetError is a global wrapper methods which delegated
// to the default client, create a request and SetErrorResult for request.
//
// Deprecated: Use SetErrorResult instead.
func SetError(error interface{}) *Request {
return defaultClient.R().SetErrorResult(error)
}
// SetErrorResult is a global wrapper methods which delegated
// to the default client, create a request and SetErrorResult for request.
func SetErrorResult(error interface{}) *Request {
return defaultClient.R().SetErrorResult(error)
}
// SetBearerAuthToken is a global wrapper methods which delegated
// to the default client, create a request and SetBearerAuthToken for request.
func SetBearerAuthToken(token string) *Request {
return defaultClient.R().SetBearerAuthToken(token)
}
// SetBasicAuth is a global wrapper methods which delegated
// to the default client, create a request and SetBasicAuth for request.
func SetBasicAuth(username, password string) *Request {
return defaultClient.R().SetBasicAuth(username, password)
}
// SetDigestAuth is a global wrapper methods which delegated
// to the default client, create a request and SetDigestAuth for request.
func SetDigestAuth(username, password string) *Request {
return defaultClient.R().SetDigestAuth(username, password)
}
// SetHeaders is a global wrapper methods which delegated
// to the default client, create a request and SetHeaders for request.
func SetHeaders(hdrs map[string]string) *Request {
return defaultClient.R().SetHeaders(hdrs)
}
// SetHeader is a global wrapper methods which delegated
// to the default client, create a request and SetHeader for request.
func SetHeader(key, value string) *Request {
return defaultClient.R().SetHeader(key, value)
}
// SetHeaderOrder is a global wrapper methods which delegated
// to the default client, create a request and SetHeaderOrder for request.
func SetHeaderOrder(keys ...string) *Request {
return defaultClient.R().SetHeaderOrder(keys...)
}
// SetPseudoHeaderOrder is a global wrapper methods which delegated
// to the default client, create a request and SetPseudoHeaderOrder for request.
func SetPseudoHeaderOrder(keys ...string) *Request {
return defaultClient.R().SetPseudoHeaderOrder(keys...)
}
// SetOutputFile is a global wrapper methods which delegated
// to the default client, create a request and SetOutputFile for request.
func SetOutputFile(file string) *Request {
return defaultClient.R().SetOutputFile(file)
}
// SetOutput is a global wrapper methods which delegated
// to the default client, create a request and SetOutput for request.
func SetOutput(output io.Writer) *Request {
return defaultClient.R().SetOutput(output)
}
// SetQueryParams is a global wrapper methods which delegated
// to the default client, create a request and SetQueryParams for request.
func SetQueryParams(params map[string]string) *Request {
return defaultClient.R().SetQueryParams(params)
}
// SetQueryParamsAnyType is a global wrapper methods which delegated
// to the default client, create a request and SetQueryParamsAnyType for request.
func SetQueryParamsAnyType(params map[string]interface{}) *Request {
return defaultClient.R().SetQueryParamsAnyType(params)
}
// SetQueryParam is a global wrapper methods which delegated
// to the default client, create a request and SetQueryParam for request.
func SetQueryParam(key, value string) *Request {
return defaultClient.R().SetQueryParam(key, value)
}
// AddQueryParam is a global wrapper methods which delegated
// to the default client, create a request and AddQueryParam for request.
func AddQueryParam(key, value string) *Request {
return defaultClient.R().AddQueryParam(key, value)
}
// AddQueryParams is a global wrapper methods which delegated
// to the default client, create a request and AddQueryParams for request.
func AddQueryParams(key string, values ...string) *Request {
return defaultClient.R().AddQueryParams(key, values...)
}
// SetPathParams is a global wrapper methods which delegated
// to the default client, create a request and SetPathParams for request.
func SetPathParams(params map[string]string) *Request {
return defaultClient.R().SetPathParams(params)
}
// SetPathParam is a global wrapper methods which delegated
// to the default client, create a request and SetPathParam for request.
func SetPathParam(key, value string) *Request {
return defaultClient.R().SetPathParam(key, value)
}
// MustGet is a global wrapper methods which delegated
// to the default client, create a request and MustGet for request.
func MustGet(url string) *Response {
return defaultClient.R().MustGet(url)
}
// Get is a global wrapper methods which delegated
// to the default client, create a request and Get for request.
func Get(url string) (*Response, error) {
return defaultClient.R().Get(url)
}
// MustPost is a global wrapper methods which delegated
// to the default client, create a request and Get for request.
func MustPost(url string) *Response {
return defaultClient.R().MustPost(url)
}
// Post is a global wrapper methods which delegated
// to the default client, create a request and Post for request.
func Post(url string) (*Response, error) {
return defaultClient.R().Post(url)
}
// MustPut is a global wrapper methods which delegated
// to the default client, create a request and MustPut for request.
func MustPut(url string) *Response {
return defaultClient.R().MustPut(url)
}
// Put is a global wrapper methods which delegated
// to the default client, create a request and Put for request.
func Put(url string) (*Response, error) {
return defaultClient.R().Put(url)
}
// MustPatch is a global wrapper methods which delegated
// to the default client, create a request and MustPatch for request.
func MustPatch(url string) *Response {
return defaultClient.R().MustPatch(url)
}
// Patch is a global wrapper methods which delegated
// to the default client, create a request and Patch for request.
func Patch(url string) (*Response, error) {
return defaultClient.R().Patch(url)
}
// MustDelete is a global wrapper methods which delegated
// to the default client, create a request and MustDelete for request.
func MustDelete(url string) *Response {
return defaultClient.R().MustDelete(url)
}
// Delete is a global wrapper methods which delegated
// to the default client, create a request and Delete for request.
func Delete(url string) (*Response, error) {
return defaultClient.R().Delete(url)
}
// MustOptions is a global wrapper methods which delegated
// to the default client, create a request and MustOptions for request.
func MustOptions(url string) *Response {
return defaultClient.R().MustOptions(url)
}
// Options is a global wrapper methods which delegated
// to the default client, create a request and Options for request.
func Options(url string) (*Response, error) {
return defaultClient.R().Options(url)
}
// MustHead is a global wrapper methods which delegated
// to the default client, create a request and MustHead for request.
func MustHead(url string) *Response {
return defaultClient.R().MustHead(url)
}
// Head is a global wrapper methods which delegated
// to the default client, create a request and Head for request.
func Head(url string) (*Response, error) {
return defaultClient.R().Head(url)
}
// SetBody is a global wrapper methods which delegated
// to the default client, create a request and SetBody for request.
func SetBody(body interface{}) *Request {
return defaultClient.R().SetBody(body)
}
// SetBodyBytes is a global wrapper methods which delegated
// to the default client, create a request and SetBodyBytes for request.
func SetBodyBytes(body []byte) *Request {
return defaultClient.R().SetBodyBytes(body)
}
// SetBodyString is a global wrapper methods which delegated
// to the default client, create a request and SetBodyString for request.
func SetBodyString(body string) *Request {
return defaultClient.R().SetBodyString(body)
}
// SetBodyJsonString is a global wrapper methods which delegated
// to the default client, create a request and SetBodyJsonString for request.
func SetBodyJsonString(body string) *Request {
return defaultClient.R().SetBodyJsonString(body)
}
// SetBodyJsonBytes is a global wrapper methods which delegated
// to the default client, create a request and SetBodyJsonBytes for request.
func SetBodyJsonBytes(body []byte) *Request {
return defaultClient.R().SetBodyJsonBytes(body)
}
// SetBodyJsonMarshal is a global wrapper methods which delegated
// to the default client, create a request and SetBodyJsonMarshal for request.
func SetBodyJsonMarshal(v interface{}) *Request {
return defaultClient.R().SetBodyJsonMarshal(v)
}
// SetBodyXmlString is a global wrapper methods which delegated
// to the default client, create a request and SetBodyXmlString for request.
func SetBodyXmlString(body string) *Request {
return defaultClient.R().SetBodyXmlString(body)
}
// SetBodyXmlBytes is a global wrapper methods which delegated
// to the default client, create a request and SetBodyXmlBytes for request.
func SetBodyXmlBytes(body []byte) *Request {
return defaultClient.R().SetBodyXmlBytes(body)
}
// SetBodyXmlMarshal is a global wrapper methods which delegated
// to the default client, create a request and SetBodyXmlMarshal for request.
func SetBodyXmlMarshal(v interface{}) *Request {
return defaultClient.R().SetBodyXmlMarshal(v)
}
// SetContentType is a global wrapper methods which delegated
// to the default client, create a request and SetContentType for request.
func SetContentType(contentType string) *Request {
return defaultClient.R().SetContentType(contentType)
}
// SetContext is a global wrapper methods which delegated
// to the default client, create a request and SetContext for request.
func SetContext(ctx context.Context) *Request {
return defaultClient.R().SetContext(ctx)
}
// DisableTrace is a global wrapper methods which delegated
// to the default client, create a request and DisableTrace for request.
func DisableTrace() *Request {
return defaultClient.R().DisableTrace()
}
// EnableTrace is a global wrapper methods which delegated
// to the default client, create a request and EnableTrace for request.
func EnableTrace() *Request {
return defaultClient.R().EnableTrace()
}
// EnableForceChunkedEncoding is a global wrapper methods which delegated
// to the default client, create a request and EnableForceChunkedEncoding for request.
func EnableForceChunkedEncoding() *Request {
return defaultClient.R().EnableForceChunkedEncoding()
}
// DisableForceChunkedEncoding is a global wrapper methods which delegated
// to the default client, create a request and DisableForceChunkedEncoding for request.
func DisableForceChunkedEncoding() *Request {
return defaultClient.R().DisableForceChunkedEncoding()
}
// EnableForceMultipart is a global wrapper methods which delegated
// to the default client, create a request and EnableForceMultipart for request.
func EnableForceMultipart() *Request {
return defaultClient.R().EnableForceMultipart()
}
// DisableForceMultipart is a global wrapper methods which delegated
// to the default client, create a request and DisableForceMultipart for request.
func DisableForceMultipart() *Request {
return defaultClient.R().DisableForceMultipart()
}
// EnableDumpTo is a global wrapper methods which delegated
// to the default client, create a request and EnableDumpTo for request.
func EnableDumpTo(output io.Writer) *Request {
return defaultClient.R().EnableDumpTo(output)
}
// EnableDumpToFile is a global wrapper methods which delegated
// to the default client, create a request and EnableDumpToFile for request.
func EnableDumpToFile(filename string) *Request {
return defaultClient.R().EnableDumpToFile(filename)
}
// SetDumpOptions is a global wrapper methods which delegated
// to the default client, create a request and SetDumpOptions for request.
func SetDumpOptions(opt *DumpOptions) *Request {
return defaultClient.R().SetDumpOptions(opt)
}
// EnableDump is a global wrapper methods which delegated
// to the default client, create a request and EnableDump for request.
func EnableDump() *Request {
return defaultClient.R().EnableDump()
}
// EnableDumpWithoutBody is a global wrapper methods which delegated
// to the default client, create a request and EnableDumpWithoutBody for request.
func EnableDumpWithoutBody() *Request {
return defaultClient.R().EnableDumpWithoutBody()
}
// EnableDumpWithoutHeader is a global wrapper methods which delegated
// to the default client, create a request and EnableDumpWithoutHeader for request.
func EnableDumpWithoutHeader() *Request {
return defaultClient.R().EnableDumpWithoutHeader()
}
// EnableDumpWithoutResponse is a global wrapper methods which delegated
// to the default client, create a request and EnableDumpWithoutResponse for request.
func EnableDumpWithoutResponse() *Request {
return defaultClient.R().EnableDumpWithoutResponse()
}
// EnableDumpWithoutRequest is a global wrapper methods which delegated
// to the default client, create a request and EnableDumpWithoutRequest for request.
func EnableDumpWithoutRequest() *Request {
return defaultClient.R().EnableDumpWithoutRequest()
}
// EnableDumpWithoutRequestBody is a global wrapper methods which delegated
// to the default client, create a request and EnableDumpWithoutRequestBody for request.
func EnableDumpWithoutRequestBody() *Request {
return defaultClient.R().EnableDumpWithoutRequestBody()
}
// EnableDumpWithoutResponseBody is a global wrapper methods which delegated
// to the default client, create a request and EnableDumpWithoutResponseBody for request.
func EnableDumpWithoutResponseBody() *Request {
return defaultClient.R().EnableDumpWithoutResponseBody()
}
// SetRetryCount is a global wrapper methods which delegated
// to the default client, create a request and SetRetryCount for request.
func SetRetryCount(count int) *Request {
return defaultClient.R().SetRetryCount(count)
}
// SetRetryInterval is a global wrapper methods which delegated
// to the default client, create a request and SetRetryInterval for request.
func SetRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Request {
return defaultClient.R().SetRetryInterval(getRetryIntervalFunc)
}
// SetRetryFixedInterval is a global wrapper methods which delegated
// to the default client, create a request and SetRetryFixedInterval for request.
func SetRetryFixedInterval(interval time.Duration) *Request {
return defaultClient.R().SetRetryFixedInterval(interval)
}
// SetRetryBackoffInterval is a global wrapper methods which delegated
// to the default client, create a request and SetRetryBackoffInterval for request.
func SetRetryBackoffInterval(min, max time.Duration) *Request {
return defaultClient.R().SetRetryBackoffInterval(min, max)
}
// SetRetryHook is a global wrapper methods which delegated
// to the default client, create a request and SetRetryHook for request.
func SetRetryHook(hook RetryHookFunc) *Request {
return defaultClient.R().SetRetryHook(hook)
}
// AddRetryHook is a global wrapper methods which delegated
// to the default client, create a request and AddRetryHook for request.
func AddRetryHook(hook RetryHookFunc) *Request {
return defaultClient.R().AddRetryHook(hook)
}
// SetRetryCondition is a global wrapper methods which delegated
// to the default client, create a request and SetRetryCondition for request.
func SetRetryCondition(condition RetryConditionFunc) *Request {
return defaultClient.R().SetRetryCondition(condition)
}
// AddRetryCondition is a global wrapper methods which delegated
// to the default client, create a request and AddRetryCondition for request.
func AddRetryCondition(condition RetryConditionFunc) *Request {
return defaultClient.R().AddRetryCondition(condition)
}
// SetUploadCallback is a global wrapper methods which delegated
// to the default client, create a request and SetUploadCallback for request.
func SetUploadCallback(callback UploadCallback) *Request {
return defaultClient.R().SetUploadCallback(callback)
}
// SetUploadCallbackWithInterval is a global wrapper methods which delegated
// to the default client, create a request and SetUploadCallbackWithInterval for request.
func SetUploadCallbackWithInterval(callback UploadCallback, minInterval time.Duration) *Request {
return defaultClient.R().SetUploadCallbackWithInterval(callback, minInterval)
}
// SetDownloadCallback is a global wrapper methods which delegated
// to the default client, create a request and SetDownloadCallback for request.
func SetDownloadCallback(callback DownloadCallback) *Request {
return defaultClient.R().SetDownloadCallback(callback)
}
// SetDownloadCallbackWithInterval is a global wrapper methods which delegated
// to the default client, create a request and SetDownloadCallbackWithInterval for request.
func SetDownloadCallbackWithInterval(callback DownloadCallback, minInterval time.Duration) *Request {
return defaultClient.R().SetDownloadCallbackWithInterval(callback, minInterval)
}
// EnableCloseConnection is a global wrapper methods which delegated
// to the default client, create a request and EnableCloseConnection for request.
func EnableCloseConnection() *Request {
return defaultClient.R().EnableCloseConnection()
}