Should resolution of route parameters be a requirement to match a route? #55092
Replies: 2 comments 1 reply
-
My suggestion is to go with the /blog/{blog:slug} and /product/{product:name} routes. I think that determine the route based on the existence of either one leads to slow pages if done for more than two... Another implication is the 404 page to show when neither exists. do you show the blog 404 or the product 404? |
Beta Was this translation helpful? Give feedback.
-
Personally, I'd make my own catch-all controller and handle the parameter resolution myself at that point. Resolving route parameters is an implementation detail of the framework IMO (it's already determined the route is matched and is now resolving the controller to handle that match), not something that should affect the behavior of matching routes. This really should be more of an edge case than a common enough requirement for frameworks to need to support this behavior in the router (and I say this as someone who's written a content integration for clients where we ultimately had a |
Beta Was this translation helpful? Give feedback.
-
given the route declarations:
and go to /foo, it will match the blog controller, try to find a blog model instance with slug 'foo', and 404 if it doesn't exist.
IMO what SHOULD happen, is the parameter resolution happen as part of determining if the route matches or not, so if no blog post is found, it will search for a product with name 'foo', if it finds one match that route, if not keep checking routes.
this functionality could be triggered with a ->continueIfMissing() method on the route declaration, allowing it to be opt in as to not break existing sites.
Beta Was this translation helpful? Give feedback.
All reactions