traefik/middlewares/compress.go

18 lines
382 B
Go
Raw Normal View History

2016-09-28 21:07:06 +00:00
package middlewares
import (
"net/http"
"github.com/NYTimes/gziphandler"
2016-09-28 21:07:06 +00:00
)
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)
}