Skip to content

Commit

Permalink
#9 - allow access to raw byte slice of response
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanHCB committed Oct 17, 2022
1 parent 995530d commit ad6f426
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions implementation/httpclient/httpclient.go
Expand Up @@ -148,10 +148,15 @@ func (c *HttpClientImpl) Perform(ctx context.Context, method string, requestUrl
}

if len(responseBody) > 0 && response.Body != nil {
err := json.Unmarshal(responseBody, response.Body)
if err != nil {
c.ResponseMetricsCallback(ctx, method, requestUrl, response.Status, err, c.Now().Sub(response.Time), len(responseBody))
return aurestnontripping.New(ctx, err)
switch response.Body.(type) {
case **[]byte:
*(response.Body.(**[]byte)) = &responseBody
default:
err := json.Unmarshal(responseBody, response.Body)
if err != nil {
c.ResponseMetricsCallback(ctx, method, requestUrl, response.Status, err, c.Now().Sub(response.Time), len(responseBody))
return aurestnontripping.New(ctx, err)
}
}
c.ResponseMetricsCallback(ctx, method, requestUrl, response.Status, nil, c.Now().Sub(response.Time), len(responseBody))
} else {
Expand Down

0 comments on commit ad6f426

Please sign in to comment.