I know how to to specify routes for page components using Mason::Plugin::RouterSimple, for example given a url of:
/archives/2015/07
I can create a component archives.mc
as this:
<%class>
route "{year:[0-9]{4}}/{month:[0-9]{2}}";
</%class>
Archives for the month of <% $.month %>/<% $.year %>
and similarly I can create a news.mc
component that will handle urls of:
/news/2012/04
and that's fine (and very elegant!) but now what I want is to be able to handle urls like the following ones:
/john/archives/2014/12
/john/news/2014/03
/peter/news/2015/09
/bill/archives/2012/06
etc. I know I can write the route rules as:
<%class>
route "{user:[a-z]+}/archives/{year:[0-9]{4}}/{month:[0-9]{2}}", { action=> 'archives' };
route "{user:[a-z]+}/news/{year:[0-9]{4}}/{month:[0-9]{2}}", { action=> 'news' };
</%class>
but then the requests have to be handled by two different components. How can I route a request to different components? archives.mc
and news.mc
won't be matched by Mason because there's a username before the name of the component.