Documentation ¶
Overview ¶
GZip Middleware for the excellent HTTPRouter from @julienschmidt http://godoc.org/github.com/julienschmidt/httprouter
Example usage:
import ( "github.com/socialradar/go-gzip-middleware" ) // ... router := httprouter.New() router.Get("/path", gzip.Middleware(HandlePath, false))
This middleware will gzip any requests with the `Accept-Encoding=gzip` header.
It also includes a bool option to force gzip all requests, regardless of whether or not that gzip header is present on the request. For example:
router.Get("/path", gzip.Middleware(HandlePath, true))
Supplying `true` as the second argument will force Gzip every response regardless of the client `Accept-Encoding` header.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(fn httprouter.Handle, force bool) httprouter.Handle
fn - The httprouter handler function force - bool, whether or not to force Gzip regardless of the sent headers.
Types ¶
type GzipResponseWriter ¶
type GzipResponseWriter struct { io.Writer http.ResponseWriter }
Click to show internal directories.
Click to hide internal directories.