Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Default error handler for mounted app #1632

Closed
lucaskatayama opened this issue Nov 27, 2021 · 1 comment · Fixed by #1649
Closed

🐛 Default error handler for mounted app #1632

lucaskatayama opened this issue Nov 27, 2021 · 1 comment · Fixed by #1649

Comments

@lucaskatayama
Copy link

Fiber version
v2.22.0
Issue description

If you mount an router in a group, the default error handler is not triggered.

Code snippet

Given router:

**Router **

func Router() *fiber.App {
	api := fiber.New(fiber.Config{
		ErrorHandler: ErrorHandler,
	})

	for _, route := range Routes {
		api.Add(route.Method, route.Path, route.Handler)
	}
	return api
}

The following code does not trigger the default error handler inside v1.Router() or v2.Router()

Main

package main

import "github.com/gofiber/fiber/v2"

func main() {
  app := fiber.New()
  api := app.Group("/api")
  api.Mount("/v1", v1.Router())
  api.Mount("/v2", v2.Router())
}

BUT if you do the following it works:

Main

package main

import "github.com/gofiber/fiber/v2"

func main() {
  app := fiber.New()
  app.Mount("/api/v1", v1.Router())
  app.Mount("/api/v2", v2.Router())
}

And the specific router error handler is called correctly.

@welcome
Copy link

welcome bot commented Nov 27, 2021

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants