title: Golang 1.7 context value nil
body: <p>I'm trying to implement a JWT (JSON web token) middleware using Go's 1.7 context package, but I'm running into a strange bug retrieving an earlier set context value..</p>
  
  <p>Given the code..</p>
  
  <pre><code>func JWTAuthenticator(next http.Handler) http.Handler {
      return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
          ctx := r.Context()
          jwtToken, _ := ctx.Value("jwt").(*jwt.Token)
  
          fmt.Printf("ctx = %+v\n", ctx)
          fmt.Printf("ctx = %+v\n", jwtToken)
  
          // Token is authenticated, pass it through
          next.ServeHTTP(w, r)
      })
  }
  </code></pre>
  
  <p>This returns ..</p>
  
  <pre><code>context.Background.WithValue(&amp;http.contextKey{name:"http-server"}, &amp;http.Server{Addr:":8080", Handler:(*chi.Mux)(0xc4201ec180), ReadTimeout:0, WriteTimeout:0, TLSConfig:(*tls.Config)(0xc420210000), MaxHeaderBytes:0, TLSNextProto:map[string]func(*http.Server, *tls.Conn, http.Handler){"h2-14":(func(*http.Server, *tls.Conn, http.Handler))(0xb8410), "h2":(func(*http.Server, *tls.Conn, http.Handler))(0xb8410)}, ConnState:(func(net.Conn, http.ConnState))(nil), ErrorLog:(*log.Logger)(nil), disableKeepAlives:0, nextProtoOnce:sync.Once{m:sync.Mutex{state:0, sema:0x0}, done:0x1}, nextProtoErr:error(nil)}).WithValue(&amp;http.contextKey{name:"local-addr"}, &amp;net.TCPAddr{IP:net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, Port:8080, Zone:""}).WithCancel.WithCancel.WithValue(&amp;chi.contextKey{name:"RouteContext"}, &amp;chi.Context{URLParams:chi.params(nil), RoutePath:"", RoutePattern:"/store", RoutePatterns:[]string{"/store"}}).WithValue(0, "us2-ldn-barlow/XJoT7aahzI-000001").WithValue("jwt", &amp;jwt.Token{Raw:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdG9yZV9pZCI6NzA4MDJ9.eT70KOJbS4JJrsMC76KH4IPRozPt-ipjMDUSuAUhB4k", Method:(*jwt.SigningMethodHMAC)(0xc420133d80), Header:map[string]interface {}{"alg":"HS256", "typ":"JWT"}, Claims:map[string]interface {}{"store_id":70802}, Signature:"eT70KOJbS4JJrsMC76KH4IPRozPt-ipjMDUSuAUhB4k", Valid:true}).WithValue("jwt.err", &lt;nil&gt;)
  
  ctx = &lt;nil&gt;
  </code></pre>
  
  <p>Which as you can does include a value .WithValue("jwt") but is returning nil!</p>
  
  <p>Any ideas?</p>