MCPcopy
hub / github.com/go-chi/chi / TestURLFormatInSubRouter

Function TestURLFormatInSubRouter

middleware/url_format_test.go:52–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func 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}

Callers

nothing calls this directly

Calls 7

RouteMethod · 0.95
UseMethod · 0.95
GetMethod · 0.95
URLParamMethod · 0.80
CloseMethod · 0.80
testRequestFunction · 0.70
WriteMethod · 0.65

Tested by

no test coverage detected