@@ -102,6 +102,14 @@ type RequestOpts struct {
102
102
MoreHeaders map [string ]string
103
103
}
104
104
105
+ func (opts * RequestOpts ) setBody (body interface {}) {
106
+ if v , ok := (body ).(io.ReadSeeker ); ok {
107
+ opts .RawBody = v
108
+ } else if body != nil {
109
+ opts .JSONBody = body
110
+ }
111
+ }
112
+
105
113
// UnexpectedResponseCodeError is returned by the Request method when a response code other than
106
114
// those listed in OkCodes is encountered.
107
115
type UnexpectedResponseCodeError struct {
@@ -268,16 +276,12 @@ func (client *ProviderClient) Get(url string, JSONResponse *interface{}, opts *R
268
276
return client .Request ("GET" , url , * opts )
269
277
}
270
278
271
- func (client * ProviderClient ) Post (url string , JSONBody interface {}, JSONResponse * interface {}, opts * RequestOpts ) (* http.Response , error ) {
279
+ func (client * ProviderClient ) Post (url string , body interface {}, JSONResponse * interface {}, opts * RequestOpts ) (* http.Response , error ) {
272
280
if opts == nil {
273
281
opts = & RequestOpts {}
274
282
}
275
283
276
- if v , ok := (JSONBody ).(io.ReadSeeker ); ok {
277
- opts .RawBody = v
278
- } else if JSONBody != nil {
279
- opts .JSONBody = JSONBody
280
- }
284
+ opts .setBody (body )
281
285
282
286
if JSONResponse != nil {
283
287
opts .JSONResponse = JSONResponse
@@ -286,16 +290,12 @@ func (client *ProviderClient) Post(url string, JSONBody interface{}, JSONRespons
286
290
return client .Request ("POST" , url , * opts )
287
291
}
288
292
289
- func (client * ProviderClient ) Put (url string , JSONBody interface {}, JSONResponse * interface {}, opts * RequestOpts ) (* http.Response , error ) {
293
+ func (client * ProviderClient ) Put (url string , body interface {}, JSONResponse * interface {}, opts * RequestOpts ) (* http.Response , error ) {
290
294
if opts == nil {
291
295
opts = & RequestOpts {}
292
296
}
293
297
294
- if v , ok := (JSONBody ).(io.ReadSeeker ); ok {
295
- opts .RawBody = v
296
- } else if JSONBody != nil {
297
- opts .JSONBody = JSONBody
298
- }
298
+ opts .setBody (body )
299
299
300
300
if JSONResponse != nil {
301
301
opts .JSONResponse = JSONResponse
0 commit comments