(t *testing.T)
| 50 | } |
| 51 | |
| 52 | func TestURLFormatInSubRouter(t *testing.T) { |
| 53 | r := chi.NewRouter() |
| 54 | |
| 55 | r.Route("/articles/{articleID}", func(r chi.Router) { |
| 56 | r.Use(URLFormat) |
| 57 | r.Get("/subroute", func(w http.ResponseWriter, r *http.Request) { |
| 58 | articleID := chi.URLParam(r, "articleID") |
| 59 | w.Write([]byte(articleID)) |
| 60 | }) |
| 61 | }) |
| 62 | |
| 63 | ts := httptest.NewServer(r) |
| 64 | defer ts.Close() |
| 65 | |
| 66 | if _, resp := testRequest(t, ts, "GET", "/articles/1/subroute.json", nil); resp != "1" { |
| 67 | t.Fatal(resp) |
| 68 | } |
| 69 | } |