Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit b13ad9a

Browse files
committed
Merge pull request #530 from kwapik/add_patch_method
[rfr] Add Patch method to ProviderClient
2 parents 7cfd38c + 136d2c2 commit b13ad9a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

provider_client.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ func defaultOkCodes(method string) []int {
246246
return []int{201, 202}
247247
case method == "PUT":
248248
return []int{201, 202}
249+
case method == "PATCH":
250+
return []int{200, 204}
249251
case method == "DELETE":
250252
return []int{202, 204}
251253
}
@@ -299,6 +301,24 @@ func (client *ProviderClient) Put(url string, JSONBody interface{}, JSONResponse
299301
return client.Request("PUT", url, *opts)
300302
}
301303

304+
func (client *ProviderClient) Patch(url string, JSONBody interface{}, JSONResponse *interface{}, opts *RequestOpts) (*http.Response, error) {
305+
if opts == nil {
306+
opts = &RequestOpts{}
307+
}
308+
309+
if v, ok := (JSONBody).(io.ReadSeeker); ok {
310+
opts.RawBody = v
311+
} else if JSONBody != nil {
312+
opts.JSONBody = JSONBody
313+
}
314+
315+
if JSONResponse != nil {
316+
opts.JSONResponse = JSONResponse
317+
}
318+
319+
return client.Request("PATCH", url, *opts)
320+
}
321+
302322
func (client *ProviderClient) Delete(url string, opts *RequestOpts) (*http.Response, error) {
303323
if opts == nil {
304324
opts = &RequestOpts{}

0 commit comments

Comments
 (0)