Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,13 @@ You can implement your own unmarshalling of responses by implementing the `Unmar

```go
type Unmarshaler interface {
Unmarshal(mimetype string, r io.Reader) error
Unmarshal(header http.Header, r io.Reader) error
}
```

The first argument to the `Unmarshal` method is the HTTP header of the response, and the second
argument is the body of the response. The method should return an error if the unmarshalling fails.

## Text Streaming Responses

The client implements a streaming text event callback which can be used to process a stream of text events,
Expand Down
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// Unmarshaler is an interface which can be implemented by a type to
// unmarshal a response body
type Unmarshaler interface {
Unmarshal(mimetype string, r io.Reader) error
Unmarshal(header http.Header, r io.Reader) error
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -333,7 +333,7 @@ func do(client *http.Client, req *http.Request, accept string, strict bool, out
}
default:
if v, ok := out.(Unmarshaler); ok {
return v.Unmarshal(mimetype, response.Body)
return v.Unmarshal(response.Header, response.Body)
} else if v, ok := out.(io.Writer); ok {
if _, err := io.Copy(v, response.Body); err != nil {
return err
Expand Down
Loading