func TestChain(t *testing.T) { is := is.New(t) site := noodle.New(gorilla.Vars, noodleMW) router := mux.NewRouter() router.Handle("/{id}", site.Then(func(c context.Context, w http.ResponseWriter, r *http.Request) error { is.Equal(gorilla.GetVars(c)["id"], "testId") is.Equal(c.Value(testKey).(string), "testValue") return nil })) r, _ := http.NewRequest("GET", "http://localhost/testId", nil) router.ServeHTTP(httptest.NewRecorder(), r) }
func products(c context.Context, w http.ResponseWriter, r *http.Request) error { vars := gorilla.GetVars(c) fmt.Fprintf(w, "products: %s", vars["id"]) return nil }