go test -run Test_Proxy_Modify_Response
(t *testing.T)
| 412 | |
| 413 | // go test -run Test_Proxy_Modify_Response |
| 414 | func Test_Proxy_Modify_Response(t *testing.T) { |
| 415 | t.Parallel() |
| 416 | |
| 417 | _, addr := createProxyTestServerIPv4(t, func(c fiber.Ctx) error { |
| 418 | return c.Status(500).SendString("not modified") |
| 419 | }) |
| 420 | |
| 421 | app := fiber.New() |
| 422 | app.Use(Balancer(Config{ |
| 423 | Servers: []string{addr}, |
| 424 | ModifyResponse: func(c fiber.Ctx) error { |
| 425 | c.Response().SetStatusCode(fiber.StatusOK) |
| 426 | return c.SendString("modified response") |
| 427 | }, |
| 428 | })) |
| 429 | |
| 430 | resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)) |
| 431 | require.NoError(t, err) |
| 432 | require.Equal(t, fiber.StatusOK, resp.StatusCode) |
| 433 | |
| 434 | b, err := io.ReadAll(resp.Body) |
| 435 | require.NoError(t, err) |
| 436 | require.Equal(t, "modified response", string(b)) |
| 437 | } |
| 438 | |
| 439 | // go test -run Test_Proxy_Modify_Request |
| 440 | func Test_Proxy_Modify_Request(t *testing.T) { |
nothing calls this directly
no test coverage detected