Skip to content

Commit

Permalink
Better examples for forward keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
bigpresh committed Feb 22, 2012
1 parent 92c15d2 commit 56acb38
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/Dancer.pm
Expand Up @@ -734,13 +734,12 @@ application.
It effectively lets you chain routes together in a clean manner.
get qr{ /demo/articles/(.+) }x => sub {
my ($article_id) = splat;
get '/demo/articles/:article_id' => sub {
# you'll have to implement this next sub yourself :)
change_the_main_database_to_demo();
forward "/articles/$article_id";
forward "/articles/" . params->{article_id};
};
In the above example, the users that reach I</demo/articles/30> will actually
Expand All @@ -759,11 +758,11 @@ B<WARNING> : Issuing a forward immediately exits the current route,
and perform the forward. Thus, any code after a forward is ignored, until the
end of the route. e.g.
get '/some/path => sub {
get '/foo/:article_id' => sub {
if ($condition) {
forward "/articles/$article_id";
forward "/articles/" . params->{article_id};
# The following code is never executed
do_stuf();
do_stuff();
}
more_stuff();
Expand Down

0 comments on commit 56acb38

Please sign in to comment.