blib/lib/JSON/RPC/Common/Marshal/Catalyst.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 29 CC 2 SCAR 12.8
CC
2
Cov
0%
write_result_to_response
6.0
post_request_to_call
2.0
BEGIN
2.0
CRAP 3.6
1 package JSON::RPC::Common::Marshal::Catalyst;
2 use Moose;
3  
4 use Carp qw(croak);
5  
6 extends qw(JSON::RPC::Common::Marshal::HTTP);
7  
8 #OVERRIDE TO CATALYST REQUEST
9 sub post_request_to_call {
10 my ( $self, $request ) = @_;
11 #read catalyst request body
12 my $body = $request->body;
13 my $content = do { local $/; <$body> };
14 $self->json_to_call( $content );
15 }
16  
17 sub write_result_to_response {
18 my ( $self, $result, $response, @args ) = @_;
19  
20 my %args = $self->result_to_response_params($result);
21  
22 foreach my $key ( keys %args ) {
23 if ( $response->can($key) ) {
24 $response->$key(delete $args{$key});
25 }
26 }
27  
28 #Copied from base class
29 #JSON::RPC::Common::Marshal::HTTP introduced a "die" here. The
30 # following keys where left over... and we were getting a "BAH" in
31 # all Catalyst requests.
32 # 'Content_Length' => 92,
33 # 'Content_Type' => 'application/json'
34 # Had to comment it out:
35 #croak "BAH" if keys %args;
36  
37 return 1;
38 }
39  
40 __PACKAGE__->meta->make_immutable();
41  
42 __PACKAGE__
43  
44 __END__