title: How enable gzip compression middleware in go-chi
body: <p>How can I enable gzip compression using the gzip middleware of the go-chi framework?</p>
  
  <p>Try using the example shown here:</p>
  
  <p><a href="https://github.com/go-chi/chi/issues/204" rel="nofollow noreferrer">https://github.com/go-chi/chi/issues/204</a></p>
  
  <p>but when I check with curl, I get this:</p>
  
  <pre><code>$ curl -H "Accept-Encoding: gzip" -I http://127.0.0.1:3333
  HTTP/1.1 405 Method Not Allowed
  Date: Sat, 31 Aug 2019 19:06:39 GMT
  </code></pre>
  
  <p>I tried the code "hello world":</p>
  
  <pre><code>package main
  
  import (
      "net/http"
  
      "github.com/go-chi/chi"
      "github.com/go-chi/chi/middleware"
  )
  
  func main() {
      r := chi.NewRouter()
      r.Use(middleware.RequestID)
      r.Use(middleware.Logger)
      //r.Use(middleware.DefaultCompress) //using this produces the same result
      r.Use(middleware.Compress(5, "gzip"))
      r.Get("/", Hello)
      http.ListenAndServe(":3333", r)
  }
  
  func Hello(w http.ResponseWriter, r *http.Request){
      w.Header().Set("Content-Type", "text/html") //according to the documentation this must be here to enable gzip
      w.Write([]byte("hello world\n"))
  }
  </code></pre>
  
  <p>but when I try to verify with curl, the result is the same</p>
  
  <pre><code>$ curl -H "Accept-Encoding: gzip" -I http://127.0.0.1:3333
  HTTP/1.1 405 Method Not Allowed
  Date: Sat, 31 Aug 2019 19:06:39 GMT
  </code></pre>
  
  <p>what's going on?</p>