Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
documentation tweaks
  • Loading branch information
kraih committed May 31, 2013
1 parent 04ceeba commit 5065000
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 84 deletions.
17 changes: 8 additions & 9 deletions lib/Mojo/Message.pm
Expand Up @@ -49,9 +49,8 @@ sub body_params {

# "multipart/formdata"
elsif ($type =~ m!multipart/form-data!i) {
for my $data (@{$self->_parse_formdata}) {
$params->append($data->[0], $data->[2]) unless defined $data->[1];
}
!defined($_->[1]) && $params->append(@$_[0, 2])
for @{$self->_parse_formdata};
}

return $params;
Expand Down Expand Up @@ -427,12 +426,12 @@ Slurp or replace C<content>.
my $params = $msg->body_params;
C<POST> parameters extracted from C<x-application-urlencoded>,
POST parameters extracted from C<x-application-urlencoded>,
C<application/x-www-form-urlencoded> or C<multipart/form-data> message body,
usually a L<Mojo::Parameters> object. Note that this method caches all data,
so it should not be called before the entire message body has been received.
Also note that message content needs to be loaded into memory to parse it, so
you have to make sure it is not excessively large.
Also note that message content needs to be loaded into memory to parse POST
parameters, so you have to make sure it is not excessively large.
# Get POST parameter value
say $msg->body_params->param('foo');
Expand Down Expand Up @@ -591,10 +590,10 @@ have to make sure it is not excessively large.
my $foo = $msg->param('foo');
my @foo = $msg->param('foo');
Access C<POST> parameters. Note that this method caches all data, so it should
Access POST parameters. Note that this method caches all data, so it should
not be called before the entire message body has been received. Also note that
message content needs to be loaded into memory to parse it, so you have to
make sure it is not excessively large.
message content needs to be loaded into memory to parse POST parameters, so
you have to make sure it is not excessively large.
=head2 parse
Expand Down
18 changes: 9 additions & 9 deletions lib/Mojo/Message/Request.pm
Expand Up @@ -385,20 +385,20 @@ Check C<X-Requested-With> header for C<XMLHttpRequest> value.
my $foo = $req->param('foo');
my @foo = $req->param('foo');
Access C<GET> and C<POST> parameters. Note that this method caches all data,
so it should not be called before the entire request body has been received.
Also note that request content needs to be loaded into memory to parse it, so
you have to make sure it is not excessively large.
Access GET and POST parameters. Note that this method caches all data, so it
should not be called before the entire request body has been received. Also
note that request content needs to be loaded into memory to parse POST
parameters, so you have to make sure it is not excessively large.
=head2 params
my $params = $req->params;
All C<GET> and C<POST> parameters, usually a L<Mojo::Parameters> object. Note
that this method caches all data, so it should not be called before the entire
All GET and POST parameters, usually a L<Mojo::Parameters> object. Note that
this method caches all data, so it should not be called before the entire
request body has been received. Also note that request content needs to be
loaded into memory to parse it, so you have to make sure it is not excessively
large.
loaded into memory to parse POST parameters, so you have to make sure it is
not excessively large.
# Get parameter value
say $req->params->param('foo');
Expand Down Expand Up @@ -426,7 +426,7 @@ Proxy URL for request.
my $params = $req->query_params;
All C<GET> parameters, usually a L<Mojo::Parameters> object.
All GET parameters, usually a L<Mojo::Parameters> object.
# Turn GET parameters to hash and extract value
say $req->query_params->to_hash->{foo};
Expand Down
44 changes: 22 additions & 22 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -814,7 +814,7 @@ L<Mojo::UserAgent::Transactor/"websocket">.
my $tx = $ua->delete(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
Perform blocking HTTP C<DELETE> request and return resulting
Perform blocking DELETE request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
L<Mojo::UserAgent::Transactor/"tx"> (except for the method). You can also
append a callback to perform requests non-blocking.
Expand All @@ -840,10 +840,10 @@ enabled with the MOJO_PROXY environment variable.
my $tx = $ua->get('http://example.com' => {DNT => 1} => form => {a => 'b'});
my $tx = $ua->get('http://example.com' => {DNT => 1} => json => {a => 'b'});
Perform blocking HTTP C<GET> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
L<Mojo::UserAgent::Transactor/"tx"> (except for the method). You can also
append a callback to perform requests non-blocking.
Perform blocking GET request and return resulting L<Mojo::Transaction::HTTP>
object, takes the same arguments as L<Mojo::UserAgent::Transactor/"tx">
(except for the method). You can also append a callback to perform requests
non-blocking.
$ua->get('http://example.com' => sub {
my ($ua, $tx) = @_;
Expand All @@ -860,10 +860,10 @@ append a callback to perform requests non-blocking.
my $tx = $ua->head(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
Perform blocking HTTP C<HEAD> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
L<Mojo::UserAgent::Transactor/"tx"> (except for the method). You can also
append a callback to perform requests non-blocking.
Perform blocking HEAD request and return resulting L<Mojo::Transaction::HTTP>
object, takes the same arguments as L<Mojo::UserAgent::Transactor/"tx">
(except for the method). You can also append a callback to perform requests
non-blocking.
$ua->head('http://example.com' => sub {
my ($ua, $tx) = @_;
Expand All @@ -886,7 +886,7 @@ Check if request for domain would use a proxy server.
my $tx = $ua->options(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
Perform blocking HTTP C<OPTIONS> request and return resulting
Perform blocking OPTIONS request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
L<Mojo::UserAgent::Transactor/"tx"> (except for the method). You can also
append a callback to perform requests non-blocking.
Expand All @@ -906,10 +906,10 @@ append a callback to perform requests non-blocking.
my $tx = $ua->patch(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
Perform blocking HTTP C<PATCH> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
L<Mojo::UserAgent::Transactor/"tx"> (except for the method). You can also
append a callback to perform requests non-blocking.
Perform blocking PATCH request and return resulting L<Mojo::Transaction::HTTP>
object, takes the same arguments as L<Mojo::UserAgent::Transactor/"tx">
(except for the method). You can also append a callback to perform requests
non-blocking.
$ua->patch('http://example.com' => sub {
my ($ua, $tx) = @_;
Expand All @@ -926,10 +926,10 @@ append a callback to perform requests non-blocking.
my $tx = $ua->post(
'http://example.com' => {DNT => 1} => json => {a => 'b'});
Perform blocking HTTP C<POST> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
L<Mojo::UserAgent::Transactor/"tx"> (except for the method). You can also
append a callback to perform requests non-blocking.
Perform blocking POST request and return resulting L<Mojo::Transaction::HTTP>
object, takes the same arguments as L<Mojo::UserAgent::Transactor/"tx">
(except for the method). You can also append a callback to perform requests
non-blocking.
$ua->post('http://example.com' => sub {
my ($ua, $tx) = @_;
Expand All @@ -944,10 +944,10 @@ append a callback to perform requests non-blocking.
my $tx = $ua->put('http://example.com' => {DNT => 1} => form => {a => 'b'});
my $tx = $ua->put('http://example.com' => {DNT => 1} => json => {a => 'b'});
Perform blocking HTTP C<PUT> request and return resulting
L<Mojo::Transaction::HTTP> object, takes the same arguments as
L<Mojo::UserAgent::Transactor/"tx"> (except for the method). You can also
append a callback to perform requests non-blocking.
Perform blocking PUT request and return resulting L<Mojo::Transaction::HTTP>
object, takes the same arguments as L<Mojo::UserAgent::Transactor/"tx">
(except for the method). You can also append a callback to perform requests
non-blocking.
$ua->put('http://example.com' => sub {
my ($ua, $tx) = @_;
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -394,8 +394,8 @@ requests, with support for content generators.
});
The C<form> content generator will automatically use query parameters for
C<GET>/C<HEAD> requests and the "application/x-www-form-urlencoded" content
type for everything else. Both get upgraded automatically to using the
GET/HEAD requests and the "application/x-www-form-urlencoded" content type for
everything else. Both get upgraded automatically to using the
"multipart/form-data" content type when necessary or when the header has been
set manually.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -602,8 +602,8 @@ Access GET/POST parameters, file uploads and route placeholder values that are
not reserved stash values. Note that this method is context sensitive in some
cases and therefore needs to be used with care, there can always be multiple
values, which might have unexpected consequences. Also note that request
content needs to be loaded into memory to parse it, so you have to make sure
it is not excessively large.
content needs to be loaded into memory to parse POST parameters, so you have
to make sure it is not excessively large.
# List context is ambiguous and should be avoided
my $hash = {foo => $self->param('foo')};
Expand Down
5 changes: 2 additions & 3 deletions lib/Mojolicious/Guides/Growing.pod
Expand Up @@ -77,9 +77,8 @@ all session state is kept client-side.
| | <- 200 OK <- | |
+---------+ +------------+

While HTTP methods such as C<PUT>, C<GET> and C<DELETE> are not directly part
of REST they go very well with it and are commonly used to manipulate
C<resources>.
While HTTP methods such as PUT, GET and DELETE are not directly part of REST
they go very well with it and are commonly used to manipulate C<resources>.

=head2 Sessions

Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -489,7 +489,7 @@ methods to pass.
$r->route('/bye')->via('GET', 'POST')
->to(controller => 'foo', action => 'bye');

With one small exception, C<HEAD> requests are considered equal to C<GET> and
With one small exception, HEAD requests are considered equal to GET and
content will not be sent with the response.

# GET /test -> {controller => 'bar', action => 'test'}
Expand All @@ -500,7 +500,7 @@ content will not be sent with the response.
=head2 WebSockets

With the method L<Mojolicious::Routes::Route/"websocket"> you can restrict
access to WebSocket handshakes, which are normal C<GET> requests with some
access to WebSocket handshakes, which are normal GET requests with some
additional information.

# /echo (WebSocket handshake)
Expand Down
14 changes: 7 additions & 7 deletions lib/Mojolicious/Lite.pm
Expand Up @@ -169,7 +169,7 @@ L<Mojolicious::Controller/"render">, but more about that later.
=head2 GET/POST parameters
All C<GET> and C<POST> parameters sent with the request are accessible via
All GET and POST parameters sent with the request are accessible via
L<Mojolicious::Controller/"param">.
use Mojolicious::Lite;
Expand Down Expand Up @@ -980,13 +980,13 @@ The L<Mojolicious::Lite> application.
my $route = del '/:foo' => sub {...};
Generate route with L<Mojolicious::Routes::Route/"delete">, matching only
C<DELETE> requests. See also the tutorial above for more argument variations.
DELETE requests. See also the tutorial above for more argument variations.
=head2 get
my $route = get '/:foo' => sub {...};
Generate route with L<Mojolicious::Routes::Route/"get">, matching only C<GET>
Generate route with L<Mojolicious::Routes::Route/"get">, matching only GET
requests. See also the tutorial above for more argument variations.
=head2 group
Expand All @@ -1012,15 +1012,15 @@ Share code with L<Mojolicious/"hook">.
my $route = options '/:foo' => sub {...};
Generate route with L<Mojolicious::Routes::Route/"options">, matching only
C<OPTIONS> requests. See also the tutorial above for more argument
OPTIONS requests. See also the tutorial above for more argument
variations.
=head2 patch
my $route = patch '/:foo' => sub {...};
Generate route with L<Mojolicious::Routes::Route/"patch">, matching only
C<PATCH> requests. See also the tutorial above for more argument variations.
PATCH requests. See also the tutorial above for more argument variations.
=head2 plugin
Expand All @@ -1033,13 +1033,13 @@ Load a plugin with L<Mojolicious/"plugin">.
my $route = post '/:foo' => sub {...};
Generate route with L<Mojolicious::Routes::Route/"post">, matching only
C<POST> requests. See also the tutorial above for more argument variations.
POST requests. See also the tutorial above for more argument variations.
=head2 put
my $route = put '/:foo' => sub {...};
Generate route with L<Mojolicious::Routes::Route/"put">, matching only C<PUT>
Generate route with L<Mojolicious::Routes::Route/"put">, matching only PUT
requests. See also the tutorial above for more argument variations.
=head2 under
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Plugin/TagHelpers.pm
Expand Up @@ -358,8 +358,8 @@ Generate file input element.
%= submit_button
% end
Generate portable form for route, path or URL. For routes that allow C<POST>
but not C<GET>, a C<method> attribute will be automatically added.
Generate portable form for route, path or URL. For routes that allow POST but
not GET, a C<method> attribute will be automatically added.
<form action="/path/to/login">
<input name="first_name" />
Expand Down
20 changes: 10 additions & 10 deletions lib/Mojolicious/Routes/Route.pm
Expand Up @@ -353,7 +353,7 @@ Generate bridge route.
my $route = $r->delete('/:foo' => sub {...});
Generate route matching only C<DELETE> requests. See also the
Generate route matching only DELETE requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
$r->delete('/user')->to('user#remove');
Expand Down Expand Up @@ -381,8 +381,8 @@ generated ones.
my $route = $r->get('/:foo' => sub {...});
Generate route matching only C<GET> requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
Generate route matching only GET requests. See also the L<Mojolicious::Lite>
tutorial for more argument variations.
$r->get('/user')->to('user#show');
Expand Down Expand Up @@ -431,7 +431,7 @@ the current route.
my $route = $r->options('/:foo' => sub {...});
Generate route matching only C<OPTIONS> requests. See also the
Generate route matching only OPTIONS requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
$r->options('/user')->to('user#overview');
Expand Down Expand Up @@ -460,26 +460,26 @@ Parse pattern.
my $route = $r->patch('/:foo' => sub {...});
Generate route matching only C<PATCH> requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
Generate route matching only PATCH requests. See also the L<Mojolicious::Lite>
tutorial for more argument variations.
$r->patch('/user')->to('user#update');
=head2 post
my $route = $r->post('/:foo' => sub {...});
Generate route matching only C<POST> requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
Generate route matching only POST requests. See also the L<Mojolicious::Lite>
tutorial for more argument variations.
$r->post('/user')->to('user#create');
=head2 put
my $route = $r->put('/:foo' => sub {...});
Generate route matching only C<PUT> requests. See also the
L<Mojolicious::Lite> tutorial for more argument variations.
Generate route matching only PUT requests. See also the L<Mojolicious::Lite>
tutorial for more argument variations.
$r->put('/user')->to('user#replace');
Expand Down

0 comments on commit 5065000

Please sign in to comment.