fiber icon indicating copy to clipboard operation
fiber copied to clipboard

🤗 [Question]: Migration from v2 -> v3

Open RajaSunrise opened this issue 7 months ago • 0 comments

Question Description

🔧 Questions: Mount() (v2) vs. Use() (v3) for Sub-Apps

  1. Behavioral Differences

    • In v2, app.Mount("/admin", adminApp) automatically inherited the parent app's settings. In v3, does app.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?
  2. 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 the logger middleware:
    a) Trigger for all routes under /admin?
    b) Execute before or after the parent app’s middleware?

  3. Configuration Propagation

    • In v2, Mount() propagated settings like app.Settings.ReadTimeout to sub-apps. Does v3’s Use():
      a) Automatically inherit parent configs?
      b) Require manual re-application (e.g., adminApp.Settings = app.Settings)?
  4. Performance Implications

    • Does Use("/prefix", subApp) in v3:
      a) Introduce overhead compared to v2’s Mount()?
      b) Affect routing efficiency for deeply nested sub-apps (e.g., /a/b/c)?

⚠️ 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’s Use() correctly delegate to v1App?
  • How would you expose only GET routes from the sub-app while blocking POST?

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.

RajaSunrise avatar Jun 03 '25 23:06 RajaSunrise