Gzip middleware for Negroni.
Mostly a copy of the Martini gzip module with small changes to make it function under Negroni. Support for setting the compression level has also been added and tests have been written. Test coverage is 100% according to 'git cover'.
package main
import (
"fmt"
"github.com/codegangsta/negroni"
"github.com/phyber/negroni-gzip/gzip"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "Welcome to the home page!")
})
n := negroni.Classic()
n.Use(gzip.Gzip(gzip.DefaultCompression))
n.UseHandler(mux)
n.Run(":3000")
}
Make sure to include the Gzip middleware above any other middleware that alter the response body.