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

Function Test_Proxy_Forward

middleware/proxy/proxy_test.go:354–372  ·  view source on GitHub ↗

go test -run Test_Proxy_Forward

(t *testing.T)

Source from the content-addressed store, hash-verified

352
353// go test -run Test_Proxy_Forward
354func Test_Proxy_Forward(t *testing.T) {
355 t.Parallel()
356
357 app := fiber.New()
358
359 _, addr := createProxyTestServerIPv4(t, func(c fiber.Ctx) error {
360 return c.SendString("forwarded")
361 })
362
363 app.Use(Forward("http://" + addr))
364
365 resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
366 require.NoError(t, err)
367 require.Equal(t, fiber.StatusOK, resp.StatusCode)
368
369 b, err := io.ReadAll(resp.Body)
370 require.NoError(t, err)
371 require.Equal(t, "forwarded", string(b))
372}
373
374// go test -run Test_Proxy_Forward_WithClient_TLSConfig
375func Test_Proxy_Forward_WithClient_TLSConfig(t *testing.T) {

Callers

nothing calls this directly

Calls 6

ForwardFunction · 0.85
TestMethod · 0.80
NewMethod · 0.65
SendStringMethod · 0.65
UseMethod · 0.65

Tested by

no test coverage detected