$r->route('/:param')->to(namespace => $version.'::Controller', action => 
'action');

середа, 25 вересня 2013 р. 18:13:56 UTC+3 користувач Albert написав:
>
> Hi all
>
> I want to implement a REST API with Mojolicious with the ability to do API 
> versioning.
>
> I had in mind something like:
>
> $r->route('/:version/api/:action', version => qr/\d+/, format => 
> 'json')->via('GET')->to(controller => 'api');
>
> so all method inside the Api controller will be available via GET, default 
> format .json
>
> However, I would like to change the controller taking into account the 
> :version. I want to have several controllers Api::Version_1, 
> Api::Version_2, ...
>
> With that scenario I need to change the routing to be able to dispatch to 
> the correct controller. 
>
> How can I achieve that? Is it possible? Is there a better approach?
>
> Thanks
>
> Albert
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to