nytimes / gziphandler

Go middleware to gzip HTTP responses
https://godoc.org/github.com/NYTimes/gziphandler
Apache License 2.0
868 stars 129 forks source link

Use functional options #43

Closed adammck closed 5 years ago

adammck commented 7 years ago

Dear Lazyweb: It would be nice if our API looked less like

gz.NewGzipLevelAndMinSize(1, 1024)(myHandler)

and more like

gz.New(myHandler, gz.CompressionLevel(1), gz.MinSize(1024))

See Functional options for friendly APIs. I'm open to other solutions, too.

jprobinson commented 7 years ago

After playing around with more and more go-kit, I've been leaning towards the latter lately.

tmthrgd commented 6 years ago

This was fixed with the merging of #51.


The main difference was that the options take the form:

wrap, _ := gz.GzipHandlerWithOpts(gz.CompressionLevel(1), gz.MinSize(1024))
wrap(myHandler)

instead of:

gz.New(myHandler, gz.CompressionLevel(1), gz.MinSize(1024))

Either this should be closed or considered a request to add the New function described above.

dolmen commented 5 years ago

If this is fixed, it might be time for close of this issue, isn't it? I'm discovering this project and most open issues seem to be in fact done. Discovering that after the read of a long discussion is unexpected.