in reply to Multiple routes that execute the same action
Sure. If you want to reuse code, you simply give it a name, and use that name twice.
sub handle_my_request { ... } for my $route ('/myaction1/:param1', '/myaction2/:param2') { get $route, \&handle_my_request; }
Most frameworks also allow you to write the code as methods in a controller class (see for example Mojolicious::Guides::Growing).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Multiple routes that execute the same action
by perl_help26 (Beadle) on Mar 28, 2014 at 13:21 UTC |
In Section
Seekers of Perl Wisdom