Skip to content

Commit 8bd6a4d

Browse files
authored
Merge pull request #42 from mutablelogic/dev
Changed Unmarshaller to use http.Header
2 parents 3607a9a + b188fb5 commit 8bd6a4d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,13 @@ You can implement your own unmarshalling of responses by implementing the `Unmar
240240

241241
```go
242242
type Unmarshaler interface {
243-
Unmarshal(mimetype string, r io.Reader) error
243+
Unmarshal(header http.Header, r io.Reader) error
244244
}
245245
```
246246

247+
The first argument to the `Unmarshal` method is the HTTP header of the response, and the second
248+
argument is the body of the response. The method should return an error if the unmarshalling fails.
249+
247250
## Text Streaming Responses
248251

249252
The client implements a streaming text event callback which can be used to process a stream of text events,

client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
// Unmarshaler is an interface which can be implemented by a type to
2525
// unmarshal a response body
2626
type Unmarshaler interface {
27-
Unmarshal(mimetype string, r io.Reader) error
27+
Unmarshal(header http.Header, r io.Reader) error
2828
}
2929

3030
///////////////////////////////////////////////////////////////////////////////
@@ -333,7 +333,7 @@ func do(client *http.Client, req *http.Request, accept string, strict bool, out
333333
}
334334
default:
335335
if v, ok := out.(Unmarshaler); ok {
336-
return v.Unmarshal(mimetype, response.Body)
336+
return v.Unmarshal(response.Header, response.Body)
337337
} else if v, ok := out.(io.Writer); ok {
338338
if _, err := io.Copy(v, response.Body); err != nil {
339339
return err

0 commit comments

Comments
 (0)