Skip to content

Commit

Permalink
more consistent explanation for HTTP request methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 5, 2014
1 parent 8b417aa commit 6aef763
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -192,24 +192,21 @@ class, but the router can be accessed from everywhere (even at runtime).
=head2 Routing destination

After you start a new route with methods like
L<Mojolicious::Routes::Route/"get"> or L<Mojolicious::Routes::Route/"any">,
you can also give it a destination in the form of a hash using the chained
method L<Mojolicious::Routes::Route/"to">.
L<Mojolicious::Routes::Route/"get">, you can also give it a destination in the
form of a hash using the chained method L<Mojolicious::Routes::Route/"to">.

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

# * /bye -> {controller => 'foo', action => 'bye'}
$r->any('/bye')->to(controller => 'foo', action => 'bye');

Now if the route matches an incoming request it will use the content of this
hash to try and find appropriate code to generate a response.

=head2 HTTP methods

There are methods for the most common HTTP methods, and
L<Mojolicious::Routes::Route/"any"> accepts an array reference with arbitrary
methods as first argument.
There are already shortcuts for the most common HTTP request methods like
L<Mojolicious::Routes::Route/"post">, and for more control
L<Mojolicious::Routes::Route/"any"> accepts an optional array reference with
arbitrary request methods as first argument.

# PUT /hello -> undef
# GET /hello -> {controller => 'foo', action => 'hello'}
Expand All @@ -218,6 +215,9 @@ methods as first argument.
# PUT /hello -> {controller => 'foo', action => 'hello'}
$r->put('/hello')->to(controller => 'foo', action => 'hello');

# POST /hello -> {controller => 'foo', action => 'hello'}
$r->post('/hello')->to(controller => 'foo', action => 'hello');

# GET|POST /bye -> {controller => 'foo', action => 'bye'}
$r->any([qw(GET POST)] => '/bye')->to(controller => 'foo', action => 'bye');

Expand Down

0 comments on commit 6aef763

Please sign in to comment.