franela/goreq — pull request #59 by sschepens (2014-07-24 23:33:59+00:00)
Title: Alternative interface for Compressions

This is the alternativ interface i had thought of, i like it because it provides a type safe/friendly way of working.
One of the laybacks of the string based Compression is that we've got no
compiler checking.
Another benefit of this interface is that it would allow for easy custom
implementations of compressions.
This creates a new struct Compression that has a ContentEncoding string,
Reader and Writer creator closures that receive a buffer to read and a
buffer to write to.

Interface Comparison:
- Current:
goreq.Request{Uri: "http://www.google.com", Compression: "gzip"}.Do()
goreq.Request{Uri: "http://www.google.com", Compression: "deflate"}.Do()
- Alternative:
goreq.Request{Uri: "http://www.google.com", Compression: goreq.Gzip()}.Do()
goreq.Request{Uri: "http://www.google.com", Compression: goreq.Deflate()}.Do()