-
-
Save jjn1056/292e44c1f43b683e38fb 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 => 'name'} => 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