(t *testing.T)
| 411 | } |
| 412 | |
| 413 | func Test_Ctx_CustomCtx_WithMiddleware(t *testing.T) { |
| 414 | t.Parallel() |
| 415 | |
| 416 | app := NewWithCustomCtx(func(app *App) CustomCtx { |
| 417 | return &customCtx{ |
| 418 | DefaultCtx: *NewDefaultCtx(app), |
| 419 | } |
| 420 | }) |
| 421 | |
| 422 | app.Use(func(c Ctx) error { |
| 423 | _, ok := c.(*customCtx) |
| 424 | require.True(t, ok) |
| 425 | return c.Next() |
| 426 | }) |
| 427 | |
| 428 | app.Get("/", func(c Ctx) error { |
| 429 | custom, ok := c.(*customCtx) |
| 430 | require.True(t, ok) |
| 431 | return c.SendString(custom.Params("")) |
| 432 | }) |
| 433 | |
| 434 | resp, err := app.Test(httptest.NewRequest(MethodGet, "/", http.NoBody)) |
| 435 | require.NoError(t, err, "app.Test(req)") |
| 436 | defer func() { require.NoError(t, resp.Body.Close()) }() |
| 437 | |
| 438 | body, err := io.ReadAll(resp.Body) |
| 439 | require.NoError(t, err, "io.ReadAll(resp.Body)") |
| 440 | require.Equal(t, "prefix_", string(body)) |
| 441 | } |
| 442 | |
| 443 | // go test -run Test_Ctx_CustomCtx |
| 444 | func Test_Ctx_CustomCtx_and_Method(t *testing.T) { |
nothing calls this directly
no test coverage detected