Catalyst::TraitFor::Request::REST(3pm) | User Contributed Perl Documentation | Catalyst::TraitFor::Request::REST(3pm) |
Catalyst::TraitFor::Request::REST - A role to apply to Catalyst::Request giving it REST methods and attributes.
if ( $c->request->accepts('application/json') ) { ... } my $types = $c->request->accepted_content_types();
This is a Moose::Role applied to Catalyst::Request that adds a few methods to the request object to facilitate writing REST-y code. Currently, these methods are all related to the content types accepted by the client and the content type sent in the request.
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.
$request->accepted_content_types->[0]
Note that this does not do any wildcard expansion of types.
See Catalyst::Action::REST for authors.
You may distribute this code under the same terms as Perl itself.
2022-06-09 | perl v5.34.0 |