Add HTTP compression
This commit is contained in:
parent
067f13b61c
commit
17546c3a08
5 changed files with 58 additions and 29 deletions
16
middlewares/compress.go
Normal file
16
middlewares/compress.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
package middlewares
|
||||
|
||||
import (
|
||||
"github.com/NYTimes/gziphandler"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Rewrite is a middleware that allows redirections
|
||||
type Compress struct {
|
||||
}
|
||||
|
||||
//
|
||||
func (_ *Compress) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||
newGzipHandler := gziphandler.GzipHandler(next)
|
||||
newGzipHandler.ServeHTTP(rw, r)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue