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

make acceptsGzip public #65

Closed meirf closed 6 years ago

meirf commented 6 years ago

It would make my use of this library much easier if my code can see whether the library will consider a request for possible compression.

Would making acceptsGzip -> AcceptsGzip as a pull request be welcome?

jprobinson commented 6 years ago

I think this has popped up a few times so I'm into adding the option to alter the default.

Instead of making that func public, perhaps we can add a func AcceptsGzip(func(*http.Request) bool) option to let folks optionally extend it?

Would that fit your use case?

meirf commented 6 years ago

That is a slick api addition and I could see it being useful to others, but I don't have an issue with the way the library is determining compression. I just want to access the logic independently.

Feel free to change the title of this issue/repurpose/close for AcceptsGzip.

adammck commented 6 years ago

This is a dupe of #34 and #48, and I think the same recommendation applies. I don't see any problem with exporting the func, but there's already a better implementation in gddo.

tmthrgd commented 6 years ago

@meirf I have an implementation based on gddo available at tmthrgd/httputils if that's useful to you.