Add support for registering handlers for different 404 routes#2217
Add support for registering handlers for different 404 routes#2217aldas merged 1 commit intolabstack:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2217 +/- ##
==========================================
+ Coverage 92.29% 92.33% +0.03%
==========================================
Files 37 37
Lines 3102 3118 +16
==========================================
+ Hits 2863 2879 +16
Misses 150 150
Partials 89 89
Continue to review full report at Codecov.
|
|
@lammel could you review this? |
lammel
left a comment
There was a problem hiding this comment.
Did a code review. Tests are looking good.
Not sure this is always intuitive, but it allows for very flexible usecases and handling not found differently on parts of a routing tree.
LGTM!
|
@aldas Could this also be added to the v5 branch? |
|
@ganigeorgiev yes. I have been planning for some time to rebase v5 branch over master to get latest stuff. I am planning to do it |
This PR adds support for registering handlers for 404 routes. Echo instance and group has now method
RouteNotFound(path string, h HandlerFunc, m ...MiddlewareFunc) *Routewhich registers handler for given path. Path supports any/path parameters and can be static (which is little bit silly but we still support it)
Custom 404 handler has priority in router over global 404 handler and 405 handling logic.
Example:
so you would have 2 404handlers in this example:
/*/images/*Routing performance is not significantly affected by this feature.
Benchstat between current master branch and this branch.