Skip to content

Commit

Permalink
added rearranging routes recipe to routing guide
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 9, 2012
1 parent 74ff0ac commit 20a147a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -642,11 +642,23 @@ unescaped and decoded to Perl characters.
use utf8;

# GET /☃ (unicode snowman) -> {controller => 'foo', action => 'snowman'}
$r->get('/☃')->to(controller => 'foo', action => 'snowman');
$r->get('/☃')->to('foo#snowman');

Just don't forget to use the L<utf8> pragma or you'll make the Unicode snowman
very sad.

=head2 Rearranging routes

Until the first request has been handled, all routes can still be moved around
or even removed. Especially for rearranging routes created by plugins this can
be very useful.

# GET /example/show -> {controller => 'example', action => 'show'}
$r->get('/show')->to('example#show')->name('show_example');
$r->any('/example')->add_child($r->find('show_example'));
$r->get('/secrets/show')->to('secrets#show')->name('show_secrets');
$r->find('show_secrets')->remove;

=head2 WebSockets

You can restrict access to WebSocket handshakes using the method
Expand Down

0 comments on commit 20a147a

Please sign in to comment.