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

🩹Fix: Startup message doesn't show correct amount of Handlers after mounting #1302

Merged
merged 4 commits into from
May 4, 2021
Merged

🩹Fix: Startup message doesn't show correct amount of Handlers after mounting #1302

merged 4 commits into from
May 4, 2021

Conversation

capthiron
Copy link
Contributor

@capthiron capthiron commented Apr 28, 2021

After mounting an App instance or Group to an existing instance (root), the handlerCount of the root is not being updated. I came across this issue when I noticed that the startup message showed Handlers=0 even though my app had mounted a router with multiple handlers.

For example...

router := New()
router.Get("/doe", func(c *Ctx) error {
    return c.SendStatus(StatusOK)
})

app := New()
app.Mount("/john", router)

... currently results in the following startup message.

image

You get the same result when mounting the router to a Group.

I fixed this by simply adding the handlerCount of the mounted instance to the root App's own handlerCount in the corresponding Mount-function of the App and Group struct.

Side note
When writing the tests I noticed that when registering a Get-Route, not 1 but 2 Handlers are being registered. This is not the case for all the other HTTP-Methods. After investigating I noticed that App.Get() not only adds the Get-Method but also the Head-Method which results in the second handler. I'm wondering whether that is this the desired behaviour or not?

Best regard, Dario ⚡

@welcome
Copy link

welcome bot commented Apr 28, 2021

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@capthiron capthiron changed the title 🩹 Fix: Startup message doesn't show correct amount of Handlers after mounting Fix: Startup message doesn't show correct amount of Handlers after mounting Apr 28, 2021
@capthiron capthiron changed the title Fix: Startup message doesn't show correct amount of Handlers after mounting 🩹Fix: Startup message doesn't show correct amount of Handlers after mounting Apr 28, 2021
Copy link
Member

@ReneWerner87 ReneWerner87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, its looking good

@ReneWerner87 ReneWerner87 merged commit a28afaa into gofiber:master May 4, 2021
@welcome
Copy link

welcome bot commented May 4, 2021

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! 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 this pull request may close these issues.

3 participants