(t *testing.T)
| 2858 | } |
| 2859 | |
| 2860 | func TestContextMiddleware(t *testing.T) { |
| 2861 | withTimeout := func(h http.Handler) http.Handler { |
| 2862 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 2863 | ctx, cancel := context.WithTimeout(r.Context(), time.Minute) |
| 2864 | defer cancel() |
| 2865 | h.ServeHTTP(w, r.WithContext(ctx)) |
| 2866 | }) |
| 2867 | } |
| 2868 | |
| 2869 | r := NewRouter() |
| 2870 | r.Handle("/path/{foo}", withTimeout(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 2871 | vars := Vars(r) |
| 2872 | if vars["foo"] != "bar" { |
| 2873 | t.Fatal("Expected foo var to be set") |
| 2874 | } |
| 2875 | }))) |
| 2876 | |
| 2877 | rec := NewRecorder() |
| 2878 | req := newRequest("GET", "/path/bar") |
| 2879 | r.ServeHTTP(rec, req) |
| 2880 | } |
| 2881 | |
| 2882 | func TestGetVarNames(t *testing.T) { |
| 2883 | r := NewRouter() |
nothing calls this directly
no test coverage detected