Skip to content

Commit

Permalink
add payload (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
at-k authored Aug 7, 2023
1 parent d223bce commit 332fc39
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/services/olhttp/olrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,19 @@ func (svc OLHTTPService) Update(r interface{}) ([]byte, error) {
// Destroy executes a HTTP destroy and removes the resource from its location in a remote
func (svc OLHTTPService) Destroy(r interface{}) ([]byte, error) {
resourceRequest := r.(OLHTTPRequest)
req, reqErr := http.NewRequest(http.MethodDelete, resourceRequest.URL, nil)
var (
req *http.Request
reqErr error
)
if resourceRequest.Payload != nil {
bodyToSend, marshErr := json.Marshal(resourceRequest.Payload)
if marshErr != nil {
return nil, customerrors.OneloginErrorWrapper(resourceRequestuestContext, marshErr)
}
req, reqErr = http.NewRequest(http.MethodDelete, resourceRequest.URL, bytes.NewBuffer(bodyToSend))
} else {
req, reqErr = http.NewRequest(http.MethodDelete, resourceRequest.URL, nil)
}
if reqErr != nil {
return nil, customerrors.OneloginErrorWrapper(resourceRequestuestContext, reqErr)
}
Expand Down

0 comments on commit 332fc39

Please sign in to comment.