diff --git a/README.md b/README.md index 0730399..00f3f56 100644 --- a/README.md +++ b/README.md @@ -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, diff --git a/client.go b/client.go index 76e4334..587f328 100644 --- a/client.go +++ b/client.go @@ -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 } /////////////////////////////////////////////////////////////////////////////// @@ -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