Add gzip compression to all of our server respones

pull/859/head
Chris Goller 2017-02-09 14:35:38 -06:00
parent 1d2dfcf17a
commit 0b8c334c9d
3 changed files with 7 additions and 1 deletions

1
Godeps
View File

@ -1,3 +1,4 @@
github.com/NYTimes/gziphandler 6710af535839f57c687b62c4c23d649f9545d885
github.com/Sirupsen/logrus 3ec0642a7fb6488f65b06f9040adc67e3990296a
github.com/boltdb/bolt 5cc10bbbc5c141029940133bb33c9e969512a698
github.com/bouk/httprouter ee8b3818a7f51fbc94cc709b5744b52c2c725e91

View File

@ -1,4 +1,5 @@
### Go
* github.com/NYTimes/gziphandler [APACHE-2.0](https://github.com/NYTimes/gziphandler/blob/master/LICENSE.md)
* github.com/Sirupsen/logrus [MIT](https://github.com/Sirupsen/logrus/blob/master/LICENSE)
* github.com/boltdb/bolt [MIT](https://github.com/boltdb/bolt/blob/master/LICENSE)
* github.com/bouk/httprouter [BSD](https://github.com/bouk/httprouter/blob/master/LICENSE)

View File

@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"github.com/NYTimes/gziphandler"
"github.com/bouk/httprouter"
"github.com/influxdata/chronograf" // When julienschmidt/httprouter v2 w/ context is out, switch
"github.com/influxdata/chronograf/jwt"
@ -119,7 +120,10 @@ func NewMux(opts MuxOpts, service Service) http.Handler {
auth := AuthAPI(opts, router)
return Logger(opts.Logger, auth)
}
return Logger(opts.Logger, router)
compressed := gziphandler.GzipHandler(router)
logged := Logger(opts.Logger, compressed)
return logged
}
// AuthAPI adds the OAuth routes if auth is enabled.