appWithConfig() — fiber Function Reference
Architecture documentation for the appWithConfig() function in earlydata_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 1b236aeb_bf33_2e17_b819_48c58c201c5e["appWithConfig()"] 89ff38ec_40bf_204e_af8c_37d168e2a1f9["earlydata_test.go"] 1b236aeb_bf33_2e17_b819_48c58c201c5e -->|defined in| 89ff38ec_40bf_204e_af8c_37d168e2a1f9 22cab21c_8426_7b52_02c4_68f2b7486d46["Test_EarlyData()"] 22cab21c_8426_7b52_02c4_68f2b7486d46 -->|calls| 1b236aeb_bf33_2e17_b819_48c58c201c5e style 1b236aeb_bf33_2e17_b819_48c58c201c5e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/earlydata/earlydata_test.go lines 27–87
func appWithConfig(t *testing.T, c *fiber.Config) *fiber.App {
t.Helper()
var app *fiber.App
if c == nil {
app = fiber.New()
} else {
app = fiber.New(*c)
}
app.Use(New())
// Middleware to test IsEarly func
const localsKeyTestValid = "earlydata_testvalid"
app.Use(func(c fiber.Ctx) error {
isEarly := IsEarly(c)
switch h := c.Get(headerName); h {
case "", headerValOff:
if isEarly {
return errors.New("is early-data even though it's not")
}
case headerValOn:
switch {
case fiber.IsMethodSafe(c.Method()):
if !isEarly {
return errors.New("should be early-data on safe HTTP methods")
}
default:
if isEarly {
return errors.New("early-data unsupported on unsafe HTTP methods")
}
}
default:
return fmt.Errorf("header has unsupported value: %s", h)
}
_ = c.Locals(localsKeyTestValid, true)
return c.Next()
})
app.Add([]string{
fiber.MethodGet,
fiber.MethodPost,
}, "/", func(c fiber.Ctx) error {
valid, ok := c.Locals(localsKeyTestValid).(bool)
if !ok {
panic(errors.New("failed to type-assert to bool"))
}
if !valid {
return errors.New("handler called even though validation failed")
}
return nil
})
return app
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does appWithConfig() do?
appWithConfig() is a function in the fiber codebase, defined in middleware/earlydata/earlydata_test.go.
Where is appWithConfig() defined?
appWithConfig() is defined in middleware/earlydata/earlydata_test.go at line 27.
What calls appWithConfig()?
appWithConfig() is called by 1 function(s): Test_EarlyData.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free