Skip to content

Commit

Permalink
update slo to return error after decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
klisiecka-splunk committed Nov 7, 2024
1 parent 1a7d4ce commit 4541e93
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ func (c *Client) executeSloRequest(ctx context.Context, url string, method strin
return nil, err
}

if resp.Body != nil {
returnedSlo := &slo.SloObject{}
err = json.NewDecoder(resp.Body).Decode(returnedSlo)
return returnedSlo, nil
} else {
if expectedValidStatus == http.StatusNoContent {
_, _ = io.Copy(io.Discard, resp.Body)
return nil, nil
}

returnedSlo := &slo.SloObject{}
err = json.NewDecoder(resp.Body).Decode(returnedSlo)
_, _ = io.Copy(io.Discard, resp.Body)
return returnedSlo, err
}

0 comments on commit 4541e93

Please sign in to comment.