Routing: optional RouteParts
We were thinking about a possibility to mark parts of the uriPattern optional. This could look something like:
$c->TYPO3Route_ServiceWithControllerAndFormat ->setUrlPattern('typo3/service/v1/[@controller].[@format](?orderby=[orderby])') ->setControllerComponentNamePattern('F3::@package::Service::Controller::@controllerController') ->setViewComponentNamePattern('F3::@package::Service::View::@controller::@action@format') ->setDefaults( array( '@package' => 'TYPO3', 'orderby' => 'id' ) );
the query part would be optional in this example. This would help to drastically reduce the amount of routes. You could do something like this too:
$c->myRoute ->setUrlPattern('typo3/service/v1/[@controller](.[@format])') ...
to mark the format suffix optional.
We'll have to resolve some logical challenges though.
E.g. we'll have to dissallow routes like this one:
$c->impossibleRoute ->setUrlPattern('static/[dynamic1](optional)[dynamic2]') ...
because the routing mechanismn could not tell where [dynamic1] ends.