TestAdapter_MixedHandlerIntegration() — fiber Function Reference
Architecture documentation for the TestAdapter_MixedHandlerIntegration() function in adapter_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD bb54114a_f049_b5e8_121c_b65f3611f835["TestAdapter_MixedHandlerIntegration()"] 3ad7a4ef_7f07_008c_234d_52c9a342aa98["adapter_test.go"] bb54114a_f049_b5e8_121c_b65f3611f835 -->|defined in| 3ad7a4ef_7f07_008c_234d_52c9a342aa98 style bb54114a_f049_b5e8_121c_b65f3611f835 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
adapter_test.go lines 429–504
func TestAdapter_MixedHandlerIntegration(t *testing.T) {
app := New()
app.Use(func(c Ctx) error {
c.Set("X-Middleware", "fiber")
return c.Next()
})
app.Use(func(_ Req, res Res, next func() error) error {
res.Set("X-Express", "middleware")
return next()
})
app.Get("/fiber", func(c Ctx) error {
c.Set("X-Route", "fiber")
return c.SendString("fiber handler")
})
app.Post("/express", func(_ Req, res Res) error {
res.Set("X-Route", "express")
return res.SendString("express handler")
})
var httpHandlerWriteErr error
app.Put("/http", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("X-Route", "http")
w.WriteHeader(http.StatusAccepted)
_, httpHandlerWriteErr = w.Write([]byte("http handler"))
})
app.Delete("/fasthttp", func(ctx *fasthttp.RequestCtx) error {
ctx.Response.Header.Set("X-Route", "fasthttp")
ctx.SetStatusCode(http.StatusCreated)
ctx.SetBodyString("fasthttp handler")
return nil
})
run := func(name string, buildRequest func() *http.Request, expectStatus int, expectBody, expectRoute string) {
t.Run(name, func(t *testing.T) {
req := buildRequest()
resp, err := app.Test(req)
require.NoError(t, err)
t.Cleanup(func() {
require.NoError(t, resp.Body.Close())
})
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, expectStatus, resp.StatusCode)
require.Equal(t, expectBody, string(body))
require.Equal(t, "fiber", resp.Header.Get("X-Middleware"))
require.Equal(t, "middleware", resp.Header.Get("X-Express"))
require.Equal(t, expectRoute, resp.Header.Get("X-Route"))
})
}
run("fiber", func() *http.Request {
return httptest.NewRequest(http.MethodGet, "/fiber", http.NoBody)
}, http.StatusOK, "fiber handler", "fiber")
run("express", func() *http.Request {
return httptest.NewRequest(http.MethodPost, "/express", http.NoBody)
}, http.StatusOK, "express handler", "express")
run("net/http", func() *http.Request {
return httptest.NewRequest(http.MethodPut, "/http", http.NoBody)
}, http.StatusAccepted, "http handler", "http")
require.NoError(t, httpHandlerWriteErr)
run("fasthttp", func() *http.Request {
return httptest.NewRequest(http.MethodDelete, "/fasthttp", http.NoBody)
}, http.StatusCreated, "fasthttp handler", "fasthttp")
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestAdapter_MixedHandlerIntegration() do?
TestAdapter_MixedHandlerIntegration() is a function in the fiber codebase, defined in adapter_test.go.
Where is TestAdapter_MixedHandlerIntegration() defined?
TestAdapter_MixedHandlerIntegration() is defined in adapter_test.go at line 429.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free