fiber
fiber copied to clipboard
🤗 [Question]: Migration from v2 -> v3
Question Description
🔧 Questions: Mount() (v2) vs. Use() (v3) for Sub-Apps
-
Behavioral Differences
- In v2,
app.Mount("/admin", adminApp)automatically inherited the parent app's settings. In v3, doesapp.Use("/admin", adminApp)preserve this behavior? - If the sub-app (
adminApp) has its own error handler (e.g.,adminApp.ErrorHandler = customHandler), will it override the parent’s error handling in v3?
- In v2,
-
Middleware Execution
adminApp := fiber.New() adminApp.Use(logger.New()) // Sub-app middleware app.Mount("/admin", adminApp)In v3, if we use
app.Use("/admin", adminApp), will theloggermiddleware:
a) Trigger for all routes under/admin?
b) Execute before or after the parent app’s middleware? -
Configuration Propagation
- In v2,
Mount()propagated settings likeapp.Settings.ReadTimeoutto sub-apps. Does v3’sUse():
a) Automatically inherit parent configs?
b) Require manual re-application (e.g.,adminApp.Settings = app.Settings)?
- In v2,
-
Performance Implications
- Does
Use("/prefix", subApp)in v3:
a) Introduce overhead compared to v2’sMount()?
b) Affect routing efficiency for deeply nested sub-apps (e.g.,/a/b/c)?
- Does
⚠️ Critical Migration Scenario
// Fiber v2
v1App := fiber.New()
v1App.Get("/users", v1Handler)
app.Mount("/api/v1", v1App) // Works
// Fiber v3 equivalent?
app.Use("/api/v1", v1App) // Does this handle ALL methods (GET/POST) under /api/v1?
v1App.Get("/users", v1Handler)
Questions:
- If a request hits
/api/v1/users, does v3’sUse()correctly delegate tov1App? - How would you expose only
GETroutes from the sub-app while blockingPOST?
Code Snippet (optional)
Checklist:
- [x] I agree to follow Fiber's Code of Conduct.
- [x] I have checked for existing issues that describe my questions prior to opening this one.
- [x] I understand that improperly formatted questions may be closed without explanation.