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

Function TestMuxRegexp

mux_test.go:1580–1594  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1578}
1579
1580func TestMuxRegexp(t *testing.T) {
1581 r := NewRouter()
1582 r.Route("/{param:[0-9]*}/test", func(r Router) {
1583 r.Get("/", func(w http.ResponseWriter, r *http.Request) {
1584 w.Write([]byte(fmt.Sprintf("Hi: %s", URLParam(r, "param"))))
1585 })
1586 })
1587
1588 ts := httptest.NewServer(r)
1589 defer ts.Close()
1590
1591 if _, body := testRequest(t, ts, "GET", "//test", nil); body != "Hi: " {
1592 t.Fatal(body)
1593 }
1594}
1595
1596func TestMuxRegexp2(t *testing.T) {
1597 r := NewRouter()

Callers

nothing calls this directly

Calls 7

RouteMethod · 0.95
GetMethod · 0.95
NewRouterFunction · 0.85
URLParamFunction · 0.85
CloseMethod · 0.80
testRequestFunction · 0.70
WriteMethod · 0.65

Tested by

no test coverage detected