Navigation Menu

Skip to content

Commit

Permalink
better descriptions for accepts method and helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 29, 2014
1 parent 4f6e1e3 commit 93165cf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -367,7 +367,7 @@ used or an empty C<204> response rendered automatically.
}

For even more advanced negotiation logic you can also use the helper
L<Mojolicious::DefaultHelpers/"accepts"> directly.
L<Mojolicious::DefaultHelpers/"accepts">.

=head2 Rendering C<exception> and C<not_found> pages

Expand Down
7 changes: 2 additions & 5 deletions lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -129,15 +129,12 @@ L<Mojolicious::Plugin::DefaultHelpers> implements the following helpers.
=head2 accepts
%= accepts->[0] // 'html'
%= accepts('html', 'json', 'txt')
%= accepts('html', 'json', 'txt') // 'html'
Select best possible representation for resource from C<Accept> request
header, C<format> stash value or C<format> GET/POST parameter with
L<Mojolicious::Types/"accepts">, defaults to returning the first extension if
no preference could be detected. Since browsers often don't really know what
they actually want, unspecific C<Accept> request headers with more than one
MIME type will be ignored, unless the C<X-Requested-With> header is set to the
value C<XMLHttpRequest>.
no preference could be detected.
return $self->render(json => {hello => 'world'}) if $self->accepts('json');
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Types.pm
Expand Up @@ -153,7 +153,7 @@ the following new ones.
Select best possible representation for resource from C<Accept> request
header, C<format> stash value or C<format> GET/POST parameter, defaults to
returning the first extension if no preference could be detected.. Since
returning the first extension if no preference could be detected. Since
browsers often don't really know what they actually want, unspecific C<Accept>
request headers with more than one MIME type will be ignored, unless the
C<X-Requested-With> header is set to the value C<XMLHttpRequest>.
Expand Down

0 comments on commit 93165cf

Please sign in to comment.