1Gzip Handler
2============
3
4This is a tiny Go package which wraps HTTP handlers to transparently gzip the
5response body, for clients which support it. Although it's usually simpler to
6leave that to a reverse proxy (like nginx or Varnish), this package is useful
7when that's undesirable.
8
9## Install
10```bash
11go get -u github.com/NYTimes/gziphandler
12```
13
14## Usage
15
16Call `GzipHandler` with any handler (an object which implements the
17`http.Handler` interface), and it'll return a new handler which gzips the
18response. For example:
19
20```go
21package main
22
23import (
24	"io"
25	"net/http"
26	"github.com/NYTimes/gziphandler"
27)
28
29func main() {
30	withoutGz := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
31		w.Header().Set("Content-Type", "text/plain")
32		io.WriteString(w, "Hello, World")
33	})
34
35	withGz := gziphandler.GzipHandler(withoutGz)
36
37	http.Handle("/", withGz)
38	http.ListenAndServe("0.0.0.0:8000", nil)
39}
40```
41
42
43## Documentation
44
45The docs can be found at [godoc.org][docs], as usual.
46
47
48## License
49
50[Apache 2.0][license].
51
52
53
54
55[docs]:     https://godoc.org/github.com/NYTimes/gziphandler
56[license]:  https://github.com/NYTimes/gziphandler/blob/master/LICENSE
57