Bump versions for release
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Request / REST.pm
CommitLineData
256c894f 1package Catalyst::Request::REST;
930013e6 2use Moose;
37694e6c 3
4use Catalyst::Utils;
f168fa3e 5use namespace::autoclean;
6
7extends 'Catalyst::Request';
e623bdf2 8with 'Catalyst::TraitFor::Request::REST';
f168fa3e 9
3bb36dca 10our $VERSION = '0.82';
f465980c 11$VERSION = eval $VERSION;
12
0745d6eb 13# Please don't take this as a recommended way to do things.
14# The code below is grotty, badly factored and mostly here for back
15# compat..
5132f5e4 16sub _insert_self_into {
37694e6c 17 my ($class, $app_class ) = @_;
27beb190 18 # the fallback to $app_class is for the (rare and deprecated) case when
19 # people are defining actions in MyApp.pm instead of in a controller.
2998eff6 20 my $app = (blessed($app_class) && $app_class->can('_application'))
21 ? $app_class->_application : Catalyst::Utils::class2appclass( $app_class ) || $app_class;
37694e6c 22
5132f5e4 23 my $req_class = $app->request_class;
24 return if $req_class->isa($class);
149182b3 25 my $req_class_meta = Moose->init_meta( for_class => $req_class );
26 return if $req_class_meta->does_role('Catalyst::TraitFor::Request::REST');
15f4af0e 27 my $meta = Moose::Meta::Class->create_anon_class(
28 superclasses => [$req_class],
29 roles => ['Catalyst::TraitFor::Request::REST'],
30 cache => 1
31 );
32 $meta->add_method(meta => sub { $meta });
33 $app->request_class($meta->name);
5132f5e4 34}
256c894f 35
f168fa3e 36__PACKAGE__->meta->make_immutable;
37__END__
38
9a76221e 39=head1 NAME
40
41Catalyst::Request::REST - A REST-y subclass of Catalyst::Request
42
43=head1 SYNOPSIS
44
d6fb033c 45 if ( $c->request->accepts('application/json') ) {
9a76221e 46 ...
47 }
48
49 my $types = $c->request->accepted_content_types();
50
51=head1 DESCRIPTION
52
38e05ec4 53This is a subclass of C<Catalyst::Request> that applies the
85aa4e18 54L<Catalyst::TraitFor::Request::REST> role to your request class. That trait
d6ece98c 55adds a few methods to the request object to facilitate writing REST-y code.
9a76221e 56
85aa4e18 57This class is only here for backwards compatibility with applications already
58subclassing this class. New code should use
59L<Catalyst::TraitFor::Request::REST> directly.
9a76221e 60
38e05ec4 61L<Catalyst::Action::REST> and L<Catalyst::Controller::REST> will arrange
62for the request trait to be applied if needed.
9a76221e 63
38e05ec4 64=head1 SEE ALSO
9a76221e 65
38e05ec4 66L<Catalyst::TraitFor::Request::REST>.
fec6d454 67
6e6e0bf9 68=head1 AUTHORS
9a76221e 69
6e6e0bf9 70See L<Catalyst::Action::REST> for authors.
fec6d454 71
9a76221e 72=head1 LICENSE
73
74You may distribute this code under the same terms as Perl itself.
75
76=cut