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

Add catch-all route if one not regeisterd yet #8

Merged
merged 4 commits into from
Mar 13, 2024
Merged

Add catch-all route if one not regeisterd yet #8

merged 4 commits into from
Mar 13, 2024

Conversation

umputun
Copy link
Member

@umputun umputun commented Mar 13, 2024

See #7

The PR adds an automatic registration of NotFoundHandler as a catch-all route, which is invoked when no other route matches the request. This handler is wrapped with all the middlewares associated with the group. This functionality is beneficial for applying middleware to all routes, including unknown ones. It enables the use of middlewares that should operate across all routes, such as logging.

If you want to disable this behavior, use the DisableNotFoundHandler() function.

This update introduces root handling functionality to the group routing. Now, if no root route ("/") is registered, a not found handler is automatically registered for the root route. This helps in utilizing middleware for all routes such as logging. Additionally, the middleware wrapping process has been refactored into a separate function to streamline the code and improve readability. The update also includes related tests and minor tweaks to existing tests. #7
@umputun umputun merged commit 6978eff into master Mar 13, 2024
2 checks passed
@umputun umputun deleted the catch-all branch March 13, 2024 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant