Cataly...t::REST(3pm)
β¨ NAME β¨
Catalyst::TraitFor::Request::REST β bestie, it's a trait (a role π) that you slap onto Catalyst::Request, and it gifts your request object a whole lil toolkit of REST methods and attributes. The manual page lives in the perl docs as Cataly...t::REST(3pm) π
πΈ SYNOPSIS πΈ
okay so here's the vibe:
if ( $c->request->accepts('application/json') ) {
...
}
my $types = $c->request->accepted_content_types();
that's it, that's the whole flex β¨
π¦ DESCRIPTION π¦
so this is a Moose::Role that gets applied to Catalyst::Request, and what it does is add a few methods onto the request object so writing REST-y code is likeβ¦ actually pleasant? no cap π«Ά
as of right now, every single one of these methods is about content types: the ones the client says it accepts, and the content type that showed up in the request. that's the whole assignment, and it ate. π
π METHODS π
data
if the request went through the Deserializer action, this method hands you back the deserialized data structure. that's it. that's the whole thing. π
accepted_content_types
returns an array reference of the content types the client accepts. iconic.
this list gets built by peeking at all of these sources:
- Content-type header β if this exists, it will always be the first type in the list. no exceptions, she goes first, main character energy. π
content-typeparameter β if the request is a GET request and there's a"content-type"parameter chillin' in the query string, this one comes before any of the types in theAcceptheader. lowkey a sneaky little override. π- Accept header β this gets parsed, and the types it finds get ordered by the relative quality specified for each type. quality matters, bestie. β
and here's the lil rule that ties it together: if a type shows up in more than one of those places, it gets ordered based on where it was first found. first come, first served, periodt. π
preferred_content_type
this just returns the first content type it finds. it's shorthand for:
$request->accepted_content_types->[0]
literally just the first one. the chosen one. π
accepts($type)
give it a content type, and it returns true if that type is accepted. slay.
β οΈ okay important caveat, don't skip this: this does not do any wildcard expansion of types. none. zero. wildcards stay wildcards. π
π«Ά AUTHORS π«Ά
for the authors, go look at Catalyst::Action::REST β they're all listed over there. β¨
π LICENSE π
you may distribute this code under the same terms as Perl itself. go wild, bestie. πΈ
and that's a wrap!! this page was served up by perl v5.40.1 on 2026-05-07, in the Cataly...t::REST(3pm) era of the perl docs. mwah, take care of her ππβ¨
π¦ where this page comes from
- ubuntu stonking: libcatalyst-action-rest-perl 1.22-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms