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

Function createRedirectServer

middleware/proxy/proxy_test.go:67–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func createRedirectServer(t *testing.T) string {
68 t.Helper()
69 app := fiber.New()
70
71 var addr string
72 app.Get("/", func(c fiber.Ctx) error {
73 c.Location("http://" + addr + "/final")
74 return c.Status(fiber.StatusMovedPermanently).SendString("redirect")
75 })
76 app.Get("/final", func(c fiber.Ctx) error {
77 return c.SendString("final")
78 })
79
80 ln, err := net.Listen(fiber.NetworkTCP4, "127.0.0.1:0")
81 require.NoError(t, err)
82 t.Cleanup(func() {
83 ln.Close() //nolint:errcheck // It is fine to ignore the error here
84 })
85 addr = ln.Addr().String()
86
87 startServer(app, ln)
88
89 return addr
90}
91
92func restoreGlobalProxyClient(t *testing.T) {
93 t.Helper()

Calls 10

startServerFunction · 0.85
ListenMethod · 0.80
AddrMethod · 0.80
NewMethod · 0.65
GetMethod · 0.65
LocationMethod · 0.65
SendStringMethod · 0.65
StatusMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected