Skip to content

Commit

Permalink
Avoid nil errors on debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ashanbrown committed Jan 16, 2019
1 parent c379b98 commit 70b186d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func (lt *loggingTransport) RoundTrip(req *http.Request) (*http.Response, error)

if Debug && req.Body != nil && err != nil {
body, err := ioutil.ReadAll(req.Body)
if err == nil {
if err == nil && body != nil {
_ = resp.Body.Close()
fmt.Printf("response: %s\n", string(body))
resp.Body = ioutil.NopCloser(bytes.NewBuffer(body))
}
Expand Down

0 comments on commit 70b186d

Please sign in to comment.