middleware/compress.go
func (c *Compressor) Handler() func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		fn := func(w http.ResponseWriter, r *http.Request) {
			encoder, encoding, cleanup := c.selectEncoder(r.Header, w)

			cw := &compressResponseWriter{
				ResponseWriter: w,
				w:              w,
				contentTypes:   c.allowedTypes,
				encoding:       encoding,
			}
			if encoder != nil {
				cw.w = encoder
			}
			// Re-add the encoder to the pool if applicable.
			defer cleanup()
			defer cw.Close()

			next.ServeHTTP(cw, r)
		}

		return http.HandlerFunc(fn)
	}

}
func (c *Compressor) Handler() func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		fn := func(w http.ResponseWriter, r *http.Request) {
			encoder, encoding, cleanup := c.selectEncoder(r.Header, w)

			cw := &compressResponseWriter{
				ResponseWriter: w,
				w:              w,
				contentTypes:   c.allowedTypes,
				encoding:       encoding,
			}
			if encoder != nil {
				cw.w = encoder
			}
			// Re-add the encoder to the pool if applicable.
			defer cleanup()
			defer cw.Close()

			next.ServeHTTP(cw, r)
		}

		return http.HandlerFunc(fn)
	}

}
// Handler returns a new middleware that will compress the response based on the
// current Compressor.