Test_FiberHandler_BodyLimit() — fiber Function Reference
Architecture documentation for the Test_FiberHandler_BodyLimit() function in adaptor_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 354f19f4_73f8_28c3_9818_092256385f27["Test_FiberHandler_BodyLimit()"] 8ec96b38_44b4_af66_6f6f_dd60f87b680c["adaptor_test.go"] 354f19f4_73f8_28c3_9818_092256385f27 -->|defined in| 8ec96b38_44b4_af66_6f6f_dd60f87b680c style 354f19f4_73f8_28c3_9818_092256385f27 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/adaptor/adaptor_test.go lines 497–554
func Test_FiberHandler_BodyLimit(t *testing.T) {
t.Parallel()
tests := []struct {
name string
bodyLimit int
bodySize int
expectedStatus int
}{
{
name: "DefaultLimitExceededReturns413",
bodySize: fiber.DefaultBodyLimit + 1024,
expectedStatus: fiber.StatusRequestEntityTooLarge,
},
{
name: "CustomLimitExceededReturns413",
bodyLimit: 1 * 1024 * 1024,
bodySize: (1 * 1024 * 1024) + 1,
expectedStatus: fiber.StatusRequestEntityTooLarge,
},
{
name: "CustomLimitAllowsLargerPayload",
bodyLimit: 2 * fiber.DefaultBodyLimit,
bodySize: fiber.DefaultBodyLimit + 512,
expectedStatus: fiber.StatusOK,
},
{
name: "ZeroLimitConfigFallsBackToDefault",
bodyLimit: 0,
bodySize: fiber.DefaultBodyLimit - 256,
expectedStatus: fiber.StatusOK,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
app := fiber.New(fiber.Config{
BodyLimit: tt.bodyLimit,
})
app.Post("/", func(c fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK)
})
handlerFunc := FiberApp(app)
body := bytes.Repeat([]byte("a"), tt.bodySize)
req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(body))
req.ContentLength = int64(len(body))
resp := httptest.NewRecorder()
handlerFunc.ServeHTTP(resp, req)
require.Equal(t, tt.expectedStatus, resp.Code)
})
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_FiberHandler_BodyLimit() do?
Test_FiberHandler_BodyLimit() is a function in the fiber codebase, defined in middleware/adaptor/adaptor_test.go.
Where is Test_FiberHandler_BodyLimit() defined?
Test_FiberHandler_BodyLimit() is defined in middleware/adaptor/adaptor_test.go at line 497.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free