-
-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Currently, each handler is wrapped individually with middleware, offering a relatively simple implementation. However, this approach has a limitation: it doesn't allow the registration of middleware that acts on both registered and unregistered routes. While this might not pose a problem in most cases, there are situations where we might want a general middleware, such as for logging, to act on all routes.
A more appropriate solution would be to apply middleware at the group level rather than on each individual route. However, all the solutions I have explored so far have been complex and introduced a significant amount of non-intuitive code.
An alternative solution is to implement a "catch-all" handler for not-found cases on the root ("/") path, but only if no other root path has already been registered. Although this approach may seem unconventional, it offers a straightforward implementation.