| 1538 | } |
| 1539 | |
| 1540 | func Test_CustomKey(t *testing.T) { |
| 1541 | t.Parallel() |
| 1542 | |
| 1543 | app := fiber.New() |
| 1544 | var called bool |
| 1545 | app.Use(New(Config{KeyGenerator: func(c fiber.Ctx) string { |
| 1546 | called = true |
| 1547 | return utils.CopyString(c.Path()) |
| 1548 | }})) |
| 1549 | |
| 1550 | app.Get("/", func(c fiber.Ctx) error { |
| 1551 | return c.SendString("hi") |
| 1552 | }) |
| 1553 | |
| 1554 | req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody) |
| 1555 | _, err := app.Test(req) |
| 1556 | require.NoError(t, err) |
| 1557 | require.True(t, called) |
| 1558 | } |
| 1559 | |
| 1560 | func Test_CustomExpiration(t *testing.T) { |
| 1561 | t.Parallel() |