func (w *gzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
	hijacker := w.ResponseWriter.(http.Hijacker)
	return hijacker.Hijack()
}
Provided in order to implement the http.Hijacker interface.
package rest
import (
	"bufio"
	"compress/gzip"
	"net"
	"net/http"
	"strings"
)
type GzipMiddleware struct{}
func (mw *GzipMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc {
	return func(w ResponseWriter, r *Request) {
		canGzip := strings.Contains(r.Header.Get("Accept-Encoding"), "gzip")
		writer := &gzipResponseWriter{w, false, canGzip, nil}
		defer func() {
			if writer.gzipWriter != nil {
				writer.gzipWriter.Close()
			}
		}()
		h(writer, r)
	}
}
type gzipResponseWriter struct {
	ResponseWriter
	wroteHeader bool
	canGzip     bool
	gzipWriter  *gzip.Writer
}
func (w *gzipResponseWriter) WriteHeader(code int) {
	w.Header().Add("Vary", "Accept-Encoding")
	if w.canGzip {
		w.Header().Set("Content-Encoding", "gzip")
	}
	w.ResponseWriter.WriteHeader(code)
	w.wroteHeader = true
}
func (w *gzipResponseWriter) WriteJson(v interface{}) error {
	b, err := w.EncodeJson(v)
	if err != nil {
		return err
	}
	_, err = w.Write(b)
	if err != nil {
		return err
	}
	return nil
}
func (w *gzipResponseWriter) Flush() {
	if !w.wroteHeader {
		w.WriteHeader(http.StatusOK)
	}
	flusher := w.ResponseWriter.(http.Flusher)
	flusher.Flush()
}
func (w *gzipResponseWriter) CloseNotify() <-chan bool {
	notifier := w.ResponseWriter.(http.CloseNotifier)
	return notifier.CloseNotify()
}