Skip to content

Commit

Permalink
added a few route examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 27, 2012
1 parent 4a4d8c4 commit 9c2380a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lib/Mojolicious/Routes/Route.pm
Expand Up @@ -378,6 +378,8 @@ Add a new child to this route.
Generate route matching any of the listed HTTP request methods or all. See
also the L<Mojolicious::Lite> tutorial for more argument variations.
$r->any('/foo/bar')->to('user#overview');
=head2 C<bridge>
my $bridge = $r->bridge;
Expand All @@ -392,6 +394,8 @@ Add a new bridge to this route as a nested child.
Generate route matching only C<DELETE> requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
$r->delete('/foo/bar')->to('user#remove');
=head2 C<detour>
$r = $r->detour(action => 'foo');
Expand Down Expand Up @@ -423,6 +427,8 @@ generated ones.
Generate route matching only C<GET> requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
$r->get('/foo/bar')->to('user#show');
=head2 C<has_conditions>
my $success = $r->has_conditions;
Expand Down Expand Up @@ -462,13 +468,17 @@ The name of this route, defaults to an automatically generated name based on
the route pattern. Note that the name C<current> is reserved for refering to
the current route.
$r->get('/foo/bar')->to('user#show')->name('show_user');
=head2 C<options>
my $route = $r->options('/:foo' => sub {...});
Generate route matching only C<OPTIONS> requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
$r->options('/foo/bar')->to('user#preferences');
=head2 C<over>
my $over = $r->over;
Expand All @@ -490,6 +500,8 @@ Parse a pattern.
Generate route matching only C<PATCH> requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
$r->patch('/foo/bar')->to('user#update');
=head2 C<post>
my $route = $r->post('/:foo' => sub {...});
Expand All @@ -504,6 +516,8 @@ L<Mojolicious::Lite> tutorial for more argument variations.
Generate route matching only C<PUT> requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
$r->put('/foo/bar')->to('user#create');
=head2 C<render>
my $path = $r->render($suffix);
Expand Down Expand Up @@ -551,8 +565,12 @@ Stringify the whole route.
my $route = $r->under(sub {...});
my $route = $r->under('/:foo');
Generate bridges. See also the L<Mojolicious::Lite> tutorial for more
argument variations.
Generate bridge. See also the L<Mojolicious::Lite> tutorial for more argument
variations.
my $auth = $r->under('/foo')->to('user#auth');
$auth->get('/bar')->to('user#show');
$auth->put('/baz')->to('user#create');
=head2 C<via>
Expand All @@ -577,6 +595,8 @@ Add a waypoint to this route as nested child.
Generate route matching only C<WebSocket> handshakes. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
$r->websocket('/echo')->to('example#echo');
=head1 SHORTCUTS
In addition to the attributes and methods above you can also call shortcuts
Expand Down

0 comments on commit 9c2380a

Please sign in to comment.