| Catalyst::Request::REST - A REST-y subclass of Catalyst::Request |
Catalyst::Request::REST - A REST-y subclass of Catalyst::Request
if ( $c->request->accepts('application/json') ) {
...
}
my $types = $c->request->accepted_content_types();
This is a subclass of Catalyst::Request that adds a few methods to
the request object to faciliate writing REST-y code. Currently, these
methods are all related to the content types accepted by the client.
Note that if you have a custom request class in your application, and it does
not inherit from Catalyst::Request::REST, your application will fail with an
error indicating a conflict the first time it tries to use
Catalyst::Request::REST's functionality. To fix this error, make sure your
custom request class inherits from Catalyst::Request::REST.
If the request went through the Deserializer action, this method will returned the deserialized data structure.
Returns an array reference of content types accepted by the client.
The list of types is created by looking at the following sources:
If this exists, this will always be the first type in the list.
If the request is a GET request and there is a "content-type" parameter in the query string, this will come before any types in the Accept header.
This will be parsed and the types found will be ordered by the relative quality specified for each type.
If a type appears in more than one of these places, it is ordered based on where it is first found.
This returns the first content type found. It is shorthand for:
$request->accepted_content_types->[0]
accepts($type)
Given a content type, this returns true if the type is accepted.
Note that this does not do any wildcard expansion of types.
Adam Jacob <adam@stalecoffee.org>, with lots of help from mst and jrockway
J. Shirley <jshirley@cpan.org>
You may distribute this code under the same terms as Perl itself.
| Catalyst::Request::REST - A REST-y subclass of Catalyst::Request |