It seems that in this situation, using an optional placeholder on the route might be the best option. If the placeholder is defined in the route itself, this definition will be used if the placeholder is not specified in the URL (otherwise, the value specified in the URL is used).
For example:
$r->any('/page/:paramVar')->to('page#doTheThing', paramVar => 'cake');
If the address "/ page" is loaded, then $self->param('paramVar') == 'cake' else, if "/ page / tree" is loaded, then $self->param('paramVar') == 'tree' .
Note. As with other placeholder values, an additional placeholder, such as paramVar, used in the above example, can be accessed through the stash function, as well as the param function: $self->stash('paramVar') .
Callum gare
source share