10 func TestNativeContextMiddleware(t *testing.T) {
11 withTimeout := func(h http.Handler) http.Handler {
12 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
13 ctx, cancel := context.WithTimeout(r.Context(), time.Minute)
15 h.ServeHTTP(w, r.WithContext(ctx))
20 r.Handle("/path/{foo}", withTimeout(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
22 if vars["foo"] != "bar" {
23 t.Fatal("Expected foo var to be set")
28 req := newRequest("GET", "/path/bar")