Skip to content

Instantly share code, notes, and snippets.

@jberger
Last active August 29, 2015 14:20
Show Gist options
  • Save jberger/0006750cdfae8f078791 to your computer and use it in GitHub Desktop.
Save jberger/0006750cdfae8f078791 to your computer and use it in GitHub Desktop.
use Mojolicious::Lite;
use Kavorka;
hook around_action => sub {
my ($next, $c, $action, $last) = @_;
if (my $info = Kavorka->info($action)) {
my $sig = $info->signature;
my @args;
for my $param ($sig->positional_params, $sig->named_params) {
my $name = $param->name;
my $sigil = $param->sigil;
$name =~ s/^\Q$sigil//;
push @args, $name if $param->named;
push @args, $c->stash($name);
}
$c->$action(@args);
} else {
$next->();
}
};
any '/:name' => {name => 'World'} => method ($name) {
$self->render(text => "Hello $name!");
};
app->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment