-
-
Save anonymous/071ec9c6ef72704d35f2 to your computer and use it in GitHub Desktop.
Wrapping a Mojolicious chain with custom code
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
$wrapped = $r->under('/')->to(cb => sub { | |
my $c = shift; | |
# Skip, without this we end up in an infinite loop. | |
$c->match->current($c->match->current + 1); | |
warn "mark 1"; | |
$c->continue; | |
warn "mark 4"; | |
# Or, for example: | |
# $c->app->db->txn_do(sub { $c->continue; }); | |
# We're already done, make sure we don't continue. | |
return; | |
}); | |
my $foo = $wrapped->under('/foo')->to(cb => sub { | |
warn "mark 2"; | |
return 1; | |
}); | |
$foo->get('/bar')->to(cb => sub { | |
warn "mark 3"; | |
shift->render(text => 'done'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment