Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ func do(client *http.Client, req *http.Request, accept string, strict bool, trac
return nil
}

// Decode the body
// Decode the body, preferring custom Unmarshaler when implemented
if v, ok := out.(Unmarshaler); ok {
return v.Unmarshal(response.Header, response.Body)
}

switch mimetype {
case ContentTypeJson, ContentTypeJsonStream:
// JSON decode is streamable
Expand All @@ -343,9 +347,7 @@ func do(client *http.Client, req *http.Request, accept string, strict bool, trac
return err
}
default:
if v, ok := out.(Unmarshaler); ok {
return v.Unmarshal(response.Header, response.Body)
} else if v, ok := out.(io.Writer); ok {
if v, ok := out.(io.Writer); ok {
if _, err := io.Copy(v, response.Body); err != nil {
return err
}
Expand Down
Loading