| 315 | } |
| 316 | |
| 317 | func Test_Route_Match_Parser(t *testing.T) { |
| 318 | t.Parallel() |
| 319 | |
| 320 | app := New() |
| 321 | |
| 322 | app.Get("/foo/:ParamName", func(c Ctx) error { |
| 323 | return c.SendString(c.Params("ParamName")) |
| 324 | }) |
| 325 | app.Get("/Foobar/*", func(c Ctx) error { |
| 326 | return c.SendString(c.Params("*")) |
| 327 | }) |
| 328 | resp, err := app.Test(httptest.NewRequest(MethodGet, "/foo/bar", http.NoBody)) |
| 329 | require.NoError(t, err, "app.Test(req)") |
| 330 | require.Equal(t, 200, resp.StatusCode, "Status code") |
| 331 | |
| 332 | body, err := io.ReadAll(resp.Body) |
| 333 | require.NoError(t, err, "app.Test(req)") |
| 334 | require.Equal(t, "bar", app.toString(body)) |
| 335 | |
| 336 | // with star |
| 337 | resp, err = app.Test(httptest.NewRequest(MethodGet, "/Foobar/test", http.NoBody)) |
| 338 | require.NoError(t, err, "app.Test(req)") |
| 339 | require.Equal(t, 200, resp.StatusCode, "Status code") |
| 340 | |
| 341 | body, err = io.ReadAll(resp.Body) |
| 342 | require.NoError(t, err, "app.Test(req)") |
| 343 | require.Equal(t, "test", app.toString(body)) |
| 344 | } |
| 345 | |
| 346 | func TestAutoRegisterHeadRoutes(t *testing.T) { |
| 347 | t.Parallel() |