Hi! Welcome to the group and to Mojolicious! For your specific question, see Mojolicious::Routes::Route->to <https://mojolicious.org/perldoc/Mojolicious/Routes/Route#to> and the bottom part of the Optional Placeholders <https://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Optional-placeholders> section of the Routing Guide <https://mojolicious.org/perldoc/Mojolicious/Guides/Routing>, specifically:
# / -> {controller => 'foo', action => 'bar'}# /users -> {controller => 'users', action => 'bar'}# /users/list -> {controller => 'users', action => 'list'} $r->get('/:controller/:action')->to('foo#bar'); Special stash values like controller and action can also be placeholders, which is very convenient especially during development, but should only be used very carefully, because every controller method becomes a potential route. All uppercase methods as well as those starting with an underscore are automatically hidden from the router and you can use "hide" in Mojolicious::Routes <https://mojolicious.org/perldoc/Mojolicious/Routes#hide> to add additional ones. To know more, please definitely read the Tutorial <https://mojolicious.org/perldoc/#TUTORIAL> and all of the Guides <https://mojolicious.org/perldoc/#GUIDES>. But if you have any more questions, please don't hesitate to ask for Support <https://mojolicious.org/perldoc/#SUPPORT>. On Wed, Jan 2, 2019 at 4:54 AM <hwmbo.l...@gmail.com> wrote: > Hi. I want to route a request to a controller that's dynamically > constructed, base on a place holder in the url. To illustrate, I want do > something like the following: > > use Mojo::Base 'Mojolicious'; > > sub startup { > > my $r = $self->routes; > > my $route = $r->get('/:customer/boxs/:id'); > > > [ somehow, extract the :customer holder into a variable $customer, then ] > > $route->( > > controller => "$customer::boxs', > > action => 'get_list', > > ); > > } > > > I tried but can't seem to find way to this, and I'm not sure if this is > possible? > Some pointer is appreciated. Thanks. > > > > -- > 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 mojolicious+unsubscr...@googlegroups.com. > To post to this group, send email to mojolicious@googlegroups.com. > Visit this group at https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- 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 mojolicious+unsubscr...@googlegroups.com. To post to this group, send email to mojolicious@googlegroups.com. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.