rest/gzip.go
func (mw *GzipMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc {
	return func(w ResponseWriter, r *Request) {
		// gzip support enabled
		canGzip := strings.Contains(r.Header.Get("Accept-Encoding"), "gzip")
		// client accepts gzip ?
		writer := &gzipResponseWriter{w, false, canGzip, nil}
		defer func() {
			// need to close gzip writer
			if writer.gzipWriter != nil {
				writer.gzipWriter.Close()
			}
		}()
		// call the handler with the wrapped writer
		h(writer, r)
	}
}
func (mw *GzipMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc {
	return func(w ResponseWriter, r *Request) {
		// gzip support enabled
		canGzip := strings.Contains(r.Header.Get("Accept-Encoding"), "gzip")
		// client accepts gzip ?
		writer := &gzipResponseWriter{w, false, canGzip, nil}
		defer func() {
			// need to close gzip writer
			if writer.gzipWriter != nil {
				writer.gzipWriter.Close()
			}
		}()
		// call the handler with the wrapped writer
		h(writer, r)
	}
}
// MiddlewareFunc makes GzipMiddleware implement the Middleware interface.