Last active
August 29, 2015 14:01
-
-
Save kraih/bbe2ffc9ed7f6fea3bb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.20.0; | |
use feature qw(postderef signatures); | |
use Mojolicious::Lite; | |
use PadWalker 'peek_sub'; | |
hook around_action => sub ($next, $c, $action, @) { | |
my @params = sort grep {s/^\$param_//} keys peek_sub($action)->%*; | |
return $c->$action($c->param(\@params)); | |
}; | |
get '/' => sub ($self, $param_a, $param_b) { | |
$self->render(json => {a => $param_a, b => $param_b}); | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment