traefik/middlewares/compress.go

17 lines
381 B
Go
Raw Normal View History

2016-09-28 21:07:06 +00:00
package middlewares
import (
"github.com/NYTimes/gziphandler"
"net/http"
)
2016-09-28 21:29:27 +00:00
// Compress is a middleware that allows redirections
2016-09-28 21:07:06 +00:00
type Compress struct {
}
2016-09-28 21:29:27 +00:00
// ServerHTTP is a function used by negroni
func (c *Compress) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
2016-09-28 21:07:06 +00:00
newGzipHandler := gziphandler.GzipHandler(next)
newGzipHandler.ServeHTTP(rw, r)
}