MCPcopy
hub / github.com/gofiber/fiber / Test_Route_Match_Middleware

Function Test_Route_Match_Middleware

router_test.go:589–614  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

587}
588
589func Test_Route_Match_Middleware(t *testing.T) {
590 t.Parallel()
591
592 app := New()
593
594 app.Use("/foo/*", func(c Ctx) error {
595 return c.SendString(c.Params("*"))
596 })
597
598 resp, err := app.Test(httptest.NewRequest(MethodGet, "/foo/*", http.NoBody))
599 require.NoError(t, err, "app.Test(req)")
600 require.Equal(t, 200, resp.StatusCode, "Status code")
601
602 body, err := io.ReadAll(resp.Body)
603 require.NoError(t, err, "app.Test(req)")
604 require.Equal(t, "*", app.toString(body))
605
606 // with param
607 resp, err = app.Test(httptest.NewRequest(MethodGet, "/foo/bar/fasel", http.NoBody))
608 require.NoError(t, err, "app.Test(req)")
609 require.Equal(t, 200, resp.StatusCode, "Status code")
610
611 body, err = io.ReadAll(resp.Body)
612 require.NoError(t, err, "app.Test(req)")
613 require.Equal(t, "bar/fasel", app.toString(body))
614}
615
616func Test_Route_Match_UnescapedPath(t *testing.T) {
617 t.Parallel()

Callers

nothing calls this directly

Calls 6

TestMethod · 0.80
toStringMethod · 0.80
NewFunction · 0.70
UseMethod · 0.65
SendStringMethod · 0.65
ParamsMethod · 0.65

Tested by

no test coverage detected