line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Request::REST; |
2
|
|
|
|
|
|
|
$Catalyst::Request::REST::VERSION = '1.20'; |
3
|
14
|
|
|
14
|
|
27530
|
use Moose; |
|
14
|
|
|
|
|
477424
|
|
|
14
|
|
|
|
|
91
|
|
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
91770
|
use Catalyst::Utils; |
|
14
|
|
|
|
|
200929
|
|
|
14
|
|
|
|
|
407
|
|
6
|
14
|
|
|
14
|
|
902
|
use namespace::autoclean; |
|
14
|
|
|
|
|
1358
|
|
|
14
|
|
|
|
|
144
|
|
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
|
|
371
|
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
|
|
|
1252
|
my $app = (blessed($app_class) && $app_class->can('_application')) |
|
|
|
33
|
|
|
|
|
19
|
|
|
|
|
|
|
? $app_class->_application : Catalyst::Utils::class2appclass( $app_class ) || $app_class; |
20
|
|
|
|
|
|
|
|
21
|
174
|
|
|
|
|
3751
|
my $req_class = $app->request_class; |
22
|
174
|
100
|
|
|
|
5703
|
return if $req_class->isa($class); |
23
|
35
|
|
|
|
|
212
|
my $req_class_meta = Moose->init_meta( for_class => $req_class ); |
24
|
35
|
|
|
|
|
17806
|
my $role = $class->_related_role; |
25
|
35
|
100
|
|
|
|
165
|
return if $req_class_meta->does_role($role); |
26
|
16
|
100
|
|
|
|
4853
|
if ($req_class eq 'Catalyst::Request') { |
27
|
10
|
|
|
|
|
49
|
$app->request_class($class); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
6
|
|
|
|
|
53
|
my $meta = Moose::Meta::Class->create_anon_class( |
31
|
|
|
|
|
|
|
superclasses => [$req_class], |
32
|
|
|
|
|
|
|
roles => [$role], |
33
|
|
|
|
|
|
|
cache => 1 |
34
|
|
|
|
|
|
|
); |
35
|
6
|
|
|
|
|
10584
|
$meta->_add_meta_method('meta'); |
36
|
6
|
|
|
|
|
487
|
$app->request_class($meta->name); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
30
|
|
|
30
|
|
75
|
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 |