line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Request::REST; |
2
|
|
|
|
|
|
|
$Catalyst::Request::REST::VERSION = '1.21'; |
3
|
14
|
|
|
14
|
|
76914
|
use Moose; |
|
14
|
|
|
|
|
373639
|
|
|
14
|
|
|
|
|
92
|
|
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
73762
|
use Catalyst::Utils; |
|
14
|
|
|
|
|
130526
|
|
|
14
|
|
|
|
|
334
|
|
6
|
14
|
|
|
14
|
|
415
|
use namespace::autoclean; |
|
14
|
|
|
|
|
1165
|
|
|
14
|
|
|
|
|
69
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Catalyst::Request'; |
9
|
|
|
|
|
|
|
with 'Catalyst::TraitFor::Request::REST'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _insert_self_into { |
15
|
174
|
|
|
174
|
|
353
|
my ($class, $app_class ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
174
|
50
|
33
|
|
|
773
|
my $app = (blessed($app_class) && $app_class->can('_application')) |
|
|
|
33
|
|
|
|
|
19
|
|
|
|
|
|
|
? $app_class->_application : Catalyst::Utils::class2appclass( $app_class ) || $app_class; |
20
|
|
|
|
|
|
|
|
21
|
174
|
|
|
|
|
2866
|
my $req_class = $app->request_class; |
22
|
174
|
100
|
|
|
|
4621
|
return if $req_class->isa($class); |
23
|
35
|
|
|
|
|
156
|
my $req_class_meta = Moose->init_meta( for_class => $req_class ); |
24
|
35
|
|
|
|
|
13249
|
my $role = $class->_related_role; |
25
|
35
|
100
|
|
|
|
98
|
return if $req_class_meta->does_role($role); |
26
|
16
|
100
|
|
|
|
3729
|
if ($req_class eq 'Catalyst::Request') { |
27
|
10
|
|
|
|
|
40
|
$app->request_class($class); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
6
|
|
|
|
|
34
|
my $meta = Moose::Meta::Class->create_anon_class( |
31
|
|
|
|
|
|
|
superclasses => [$req_class], |
32
|
|
|
|
|
|
|
roles => [$role], |
33
|
|
|
|
|
|
|
cache => 1 |
34
|
|
|
|
|
|
|
); |
35
|
6
|
|
|
|
|
13187
|
$meta->_add_meta_method('meta'); |
36
|
6
|
|
|
|
|
373
|
$app->request_class($meta->name); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
30
|
|
|
30
|
|
59
|
sub _related_role { 'Catalyst::TraitFor::Request::REST' } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Catalyst::Request::REST - A REST-y subclass of Catalyst::Request |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
if ( $c->request->accepts('application/json') ) { |
55
|
|
|
|
|
|
|
... |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $types = $c->request->accepted_content_types(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This is a subclass of C<Catalyst::Request> that applies the |
63
|
|
|
|
|
|
|
L<Catalyst::TraitFor::Request::REST> role to your request class. That trait |
64
|
|
|
|
|
|
|
adds a few methods to the request object to facilitate writing REST-y code. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This class is only here for backwards compatibility with applications already |
67
|
|
|
|
|
|
|
subclassing this class. New code should use |
68
|
|
|
|
|
|
|
L<Catalyst::TraitFor::Request::REST> directly. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L<Catalyst::Action::REST> and L<Catalyst::Controller::REST> will arrange |
71
|
|
|
|
|
|
|
for the request trait to be applied if needed. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SEE ALSO |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L<Catalyst::TraitFor::Request::REST>. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHORS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
See L<Catalyst::Action::REST> for authors. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
You may distribute this code under the same terms as Perl itself. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|