🩹Fix: Startup message doesn't show correct amount of Handlers after mounting #1302
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After mounting an
App
instance orGroup
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 showedHandlers=0
even though my app had mounted a router with multiple handlers.For example...
... currently results in the following startup message.
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 ⚡