Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Catalyst / Request / REST.pm
1 package Catalyst::Request::REST;
2 use Moose;
3
4 use Catalyst::Utils;
5 use namespace::autoclean;
6
7 extends 'Catalyst::Request';
8 with 'Catalyst::TraitFor::Request::REST';
9
10 our $VERSION = '0.85';
11 $VERSION = eval $VERSION;
12
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..
16 sub _insert_self_into {
17   my ($class, $app_class ) = @_;
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.
20   my $app = (blessed($app_class) && $app_class->can('_application'))
21         ? $app_class->_application : Catalyst::Utils::class2appclass( $app_class ) || $app_class;
22
23   my $req_class = $app->request_class;
24   return if $req_class->isa($class);
25   my $req_class_meta = Moose->init_meta( for_class => $req_class );
26   return if $req_class_meta->does_role('Catalyst::TraitFor::Request::REST');
27   if ($req_class eq 'Catalyst::Request') {
28     $app->request_class($class);
29   }
30   else {
31       my $meta = Moose::Meta::Class->create_anon_class(
32           superclasses => [$req_class],
33           roles => ['Catalyst::TraitFor::Request::REST'],
34           cache => 1
35       );
36       $meta->add_method(meta => sub { $meta });
37       $app->request_class($meta->name);
38   }
39 }
40
41 __PACKAGE__->meta->make_immutable;
42 __END__
43
44 =head1 NAME
45
46 Catalyst::Request::REST - A REST-y subclass of Catalyst::Request
47
48 =head1 SYNOPSIS
49
50      if ( $c->request->accepts('application/json') ) {
51          ...
52      }
53
54      my $types = $c->request->accepted_content_types();
55
56 =head1 DESCRIPTION
57
58 This is a subclass of C<Catalyst::Request> that applies the
59 L<Catalyst::TraitFor::Request::REST> role to your request class. That trait
60 adds a few methods to the request object to facilitate writing REST-y code.
61
62 This class is only here for backwards compatibility with applications already
63 subclassing this class. New code should use
64 L<Catalyst::TraitFor::Request::REST> directly.
65
66 L<Catalyst::Action::REST> and L<Catalyst::Controller::REST> will arrange
67 for the request trait to be applied if needed.
68
69 =head1 SEE ALSO
70
71 L<Catalyst::TraitFor::Request::REST>.
72
73 =head1 AUTHORS
74
75 See L<Catalyst::Action::REST> for authors.
76
77 =head1 LICENSE
78
79 You may distribute this code under the same terms as Perl itself.
80
81 =cut