line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Action::Deserialize::JSON; |
2
|
|
|
|
|
|
|
$Catalyst::Action::Deserialize::JSON::VERSION = '1.21'; |
3
|
2
|
|
|
2
|
|
12
|
use Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
4
|
2
|
|
|
2
|
|
11213
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
19
|
|
5
|
2
|
|
|
2
|
|
133
|
use Scalar::Util qw(openhandle); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
138
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'Catalyst::Action'; |
8
|
2
|
|
|
2
|
|
11
|
use JSON::MaybeXS qw(JSON); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
551
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub execute { |
11
|
6
|
|
|
6
|
1
|
14
|
my $self = shift; |
12
|
6
|
|
|
|
|
13
|
my ( $controller, $c, $test ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
|
|
8
|
my $rbody; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
6
|
100
|
|
|
|
119
|
if ( my $body = $c->request->body ) { |
18
|
5
|
50
|
|
|
|
472
|
if(openhandle $body) { |
19
|
5
|
|
|
|
|
62
|
seek($body, 0, 0); |
20
|
5
|
|
|
|
|
70
|
while ( defined( my $line = <$body> ) ) { |
21
|
5
|
|
|
|
|
27
|
$rbody .= $line; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} else { |
24
|
0
|
|
|
|
|
0
|
$rbody = $body; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
6
|
100
|
|
|
|
107
|
if ( $rbody ) { |
29
|
5
|
|
|
|
|
18
|
my $json = JSON->new->utf8; |
30
|
5
|
100
|
|
|
|
56
|
if (my $options = $controller->{json_options}) { |
31
|
1
|
|
|
|
|
4
|
foreach my $opt (keys %$options) { |
32
|
1
|
|
|
|
|
5
|
$json->$opt( $options->{$opt} ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
5
|
|
|
|
|
8
|
my $rdata = eval { $json->decode( $rbody ) }; |
|
5
|
|
|
|
|
51
|
|
36
|
5
|
100
|
|
|
|
14
|
if ($@) { |
37
|
2
|
|
|
|
|
10
|
return $@; |
38
|
|
|
|
|
|
|
} |
39
|
3
|
|
|
|
|
69
|
$c->request->data($rdata); |
40
|
|
|
|
|
|
|
} else { |
41
|
1
|
50
|
|
|
|
4
|
$c->log->debug( |
42
|
|
|
|
|
|
|
'I would have deserialized, but there was nothing in the body!') |
43
|
|
|
|
|
|
|
if $c->debug; |
44
|
|
|
|
|
|
|
} |
45
|
4
|
|
|
|
|
15
|
return 1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|