line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Request::REST; |
2
|
|
|
|
|
|
|
$Catalyst::Request::REST::VERSION = '1.19'; |
3
|
14
|
|
|
14
|
|
20395
|
use Moose; |
|
14
|
|
|
|
|
372124
|
|
|
14
|
|
|
|
|
90
|
|
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
77015
|
use Catalyst::Utils; |
|
14
|
|
|
|
|
132760
|
|
|
14
|
|
|
|
|
362
|
|
6
|
14
|
|
|
14
|
|
507
|
use namespace::autoclean; |
|
14
|
|
|
|
|
1096
|
|
|
14
|
|
|
|
|
114
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Catalyst::Request'; |
9
|
|
|
|
|
|
|
with 'Catalyst::TraitFor::Request::REST'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Please don't take this as a recommended way to do things. |
12
|
|
|
|
|
|
|
# The code below is grotty, badly factored and mostly here for back |
13
|
|
|
|
|
|
|
# compat.. |
14
|
|
|
|
|
|
|
sub _insert_self_into { |
15
|
174
|
|
|
174
|
|
348
|
my ($class, $app_class ) = @_; |
16
|
|
|
|
|
|
|
# the fallback to $app_class is for the (rare and deprecated) case when |
17
|
|
|
|
|
|
|
# people are defining actions in MyApp.pm instead of in a controller. |
18
|
174
|
50
|
33
|
|
|
1282
|
my $app = (blessed($app_class) && $app_class->can('_application')) |
|
|
|
33
|
|
|
|
|
19
|
|
|
|
|
|
|
? $app_class->_application : Catalyst::Utils::class2appclass( $app_class ) || $app_class; |
20
|
|
|
|
|
|
|
|
21
|
174
|
|
|
|
|
3543
|
my $req_class = $app->request_class; |
22
|
174
|
100
|
|
|
|
5672
|
return if $req_class->isa($class); |
23
|
34
|
|
|
|
|
223
|
my $req_class_meta = Moose->init_meta( for_class => $req_class ); |
24
|
34
|
|
|
|
|
14849
|
my $role = $class->_related_role; |
25
|
34
|
100
|
|
|
|
213
|
return if $req_class_meta->does_role($role); |
26
|
15
|
100
|
|
|
|
3612
|
if ($req_class eq 'Catalyst::Request') { |
27
|
10
|
|
|
|
|
54
|
$app->request_class($class); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
5
|
|
|
|
|
41
|
my $meta = Moose::Meta::Class->create_anon_class( |
31
|
|
|
|
|
|
|
superclasses => [$req_class], |
32
|
|
|
|
|
|
|
roles => [$role], |
33
|
|
|
|
|
|
|
cache => 1 |
34
|
|
|
|
|
|
|
); |
35
|
5
|
|
|
|
|
8607
|
$meta->_add_meta_method('meta'); |
36
|
5
|
|
|
|
|
357
|
$app->request_class($meta->name); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
29
|
|
|
29
|
|
77
|
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 |