Last active
August 29, 2015 14:20
-
-
Save jberger/0006750cdfae8f078791 to your computer and use it in GitHub Desktop.
This file contains 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 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