ant0ine / go-json-rest

A quick and easy way to setup a RESTful JSON API
https://ant0ine.github.io/go-json-rest/
MIT License
3.51k stars 381 forks source link

test: allow helpers to handle gzipped responses #215

Closed athomason closed 7 years ago

athomason commented 7 years ago

While MakeSimpleRequest sets Accept-Encoding: gzip, it doesn't itself handle gzipped response bodies.

This updates the two functions which currently reference r.Body (BodyIs and DecodeJsonPayload) to use a new helper function DecodedBody which transparently handles gzipped response bodies. A matching convenience method on the Recorded type is added as well.

Updates https://github.com/ant0ine/go-json-rest/issues/214

ant0ine commented 7 years ago

Nice addition! Thanks for including the unit tests.

athomason commented 7 years ago

Cheers!