Skip to content

Instantly share code, notes, and snippets.

@kraih
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kraih/bbe2ffc9ed7f6fea3bb3 to your computer and use it in GitHub Desktop.
Save kraih/bbe2ffc9ed7f6fea3bb3 to your computer and use it in GitHub Desktop.
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