code: func (g Gzip) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
  	if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
  		return g.Next.ServeHTTP(w, r)
  	}
  outer:
  	for _, c := range g.Configs {
  
  		// Check request filters to determine if gzipping is permitted for this request
  		for _, filter := range c.RequestFilters {
  			if !filter.ShouldCompress(r) {
  				continue outer
  			}
  		}
  
  		// gzipWriter modifies underlying writer at init,
  		// use a discard writer instead to leave ResponseWriter in
  		// original form.
  		gzipWriter, err := newWriter(c, ioutil.Discard)
  		if err != nil {
  			// should not happen
  			return http.StatusInternalServerError, err
  		}
  		defer gzipWriter.Close()
  		gz := &gzipResponseWriter{Writer: gzipWriter, ResponseWriter: w}
  
  		var rw http.ResponseWriter
  		// if no response filter is used
  		if len(c.ResponseFilters) == 0 {
  			// replace discard writer with ResponseWriter
  			gzipWriter.Reset(w)
  			rw = gz
  		} else {
  			// wrap gzip writer with ResponseFilterWriter
  			rw = NewResponseFilterWriter(c.ResponseFilters, gz)
  		}
  
  		// Any response in forward middleware will now be compressed
  		status, err := g.Next.ServeHTTP(rw, r)
  
  		// If there was an error that remained unhandled, we need
  		// to send something back before gzipWriter gets closed at
  		// the return of this method!
  		if status >= 400 {
  			httpserver.DefaultErrorFunc(w, r, status)
  			return 0, err
  		}
  		return status, err
  	}
  
  	// no matching filter
  	return g.Next.ServeHTTP(w, r)
  }
docs: // ServeHTTP serves a gzipped response if the client supports it.