refactor deserialize RequestRole
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Request / REST.pm
CommitLineData
256c894f 1#
2# REST.pm
be3c588a 3# Created by: Adam Jacob, Marchex, <adam@hjksolutions.com>
256c894f 4# Created on: 10/13/2006 03:54:33 PM PDT
5#
6# $Id: $
7
8package Catalyst::Request::REST;
9
10use strict;
11use warnings;
12
774437bb 13use Moose;
3ede9e11 14extends qw/Catalyst::Request/;
15with qw/Catalyst::RequestRole::REST Catalyst::RequestRole::Deserialize/;
37694e6c 16
17use Catalyst::Utils;
256c894f 18
5132f5e4 19sub _insert_self_into {
37694e6c 20 my ($class, $app_class ) = @_;
27beb190 21 # the fallback to $app_class is for the (rare and deprecated) case when
22 # people are defining actions in MyApp.pm instead of in a controller.
37694e6c 23 my $app = Catalyst::Utils::class2appclass( $app_class ) || $app_class;
24
5132f5e4 25 my $req_class = $app->request_class;
26 return if $req_class->isa($class);
27 if ($req_class eq 'Catalyst::Request') {
28 $app->request_class($class);
29 } else {
30 die "$app has a custom request class $req_class, "
31 . "which is not a $class; see Catalyst::Request::REST";
32 }
33}
256c894f 34
9a76221e 35=head1 NAME
36
37Catalyst::Request::REST - A REST-y subclass of Catalyst::Request
38
9a76221e 39=head1 AUTHOR
40
41Adam Jacob <adam@stalecoffee.org>, with lots of help from mst and jrockway
42
fec6d454 43=head1 MAINTAINER
44
45J. Shirley <jshirley@cpan.org>
46
9a76221e 47=head1 LICENSE
48
49You may distribute this code under the same terms as Perl itself.
50
51=cut
52
531;