I've got some controllers that can handle multiple routes, usually a static and a dynamic variant of the same route, such as
. Since both routes navigate to the same page, I use the same controller and ideally, I'd like to use the same handler for both routes as well. If the optional parameter is not defined by the url, I can just fall back to a default value instead.
At the moment, this is rather flakey because the handler receives the same amount of arguments, but different data depending if the route was static or dynamic:
this._execHandler(context, handler, [path], route);.
this._execHandler(context, handler, matches, route);.
As you can see, in the case of static routes, the route's handler gets called with one argument containing the matched static path. Yet in the case of dynamic routes, the route's handler gets called with one or more arguments each containing a parameter extracted from the url, but no copies of the full path.
Further complicating thing, the handler also gets no notification of which route has been triggered, making it impossible to distinguish if the static or dynamic route has been triggered.
I would like to propose returning both the entire matched path, and the extracted parameters from the matched route. Perhaps even a hash of key-value pairs for matched parameters in dynamic routes. This way, it's much easier to determine what's going on.
I'll be implementing something like this for my current project, but if it's something you'd like to see in enyo core, I can create a pull-request.