line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::HTTP::Spore::Middleware::Format::Auto; |
2
|
|
|
|
|
|
|
$Net::HTTP::Spore::Middleware::Format::Auto::VERSION = '0.09'; |
3
|
1
|
|
|
1
|
|
567
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
6313
|
use MooseX::Types::Moose qw/HashRef Object/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
14
|
|
5
|
|
|
|
|
|
|
extends 'Net::HTTP::Spore::Middleware::Format'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4552
|
use Try::Tiny; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
285
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has serializer => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
isa => HashRef [Object], |
12
|
|
|
|
|
|
|
lazy => 1, |
13
|
|
|
|
|
|
|
default => sub { {} }, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub call { |
17
|
0
|
|
|
0
|
1
|
|
my ( $self, $req ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $formats = $req->env->{'spore.format'}; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
foreach my $format (@$formats) { |
22
|
0
|
|
|
|
|
|
my $cls = "Net::HTTP::Spore::Middleware::Format::" . $format; |
23
|
0
|
0
|
|
|
|
|
if ( Class::MOP::load($cls) ) { |
24
|
0
|
|
|
|
|
|
my $s = $cls->new; |
25
|
0
|
|
|
|
|
|
$self->serializer->{$format} = $s; |
26
|
|
|
|
|
|
|
try { |
27
|
0
|
0
|
|
0
|
|
|
if ( $req->env->{'spore.payload'} ) { |
28
|
|
|
|
|
|
|
$req->env->{'spore.payload'} = |
29
|
0
|
|
|
|
|
|
$s->encode( $req->env->{'spore.payload'} ); |
30
|
0
|
|
|
|
|
|
$req->header( $s->content_type ); |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
$req->header( $s->accept_type ); |
33
|
0
|
|
|
|
|
|
$req->env->{$self->serializer_key} = 1; |
34
|
0
|
|
|
|
|
|
}; |
35
|
0
|
0
|
|
|
|
|
last if $req->env->{$self->serializer_key} == 1; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return $self->response_cb( |
40
|
|
|
|
|
|
|
sub { |
41
|
0
|
|
|
0
|
|
|
my $res = shift; |
42
|
0
|
|
|
|
|
|
return $res; |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=encoding UTF-8 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Net::HTTP::Spore::Middleware::Format::Auto |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 VERSION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
version 0.09 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
B<NOT WORKING> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHORS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over 4 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item * |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Franck Cuny <franck.cuny@gmail.com> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Ash Berlin <ash@cpan.org> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Ahmad Fatoum <athreef@cpan.org> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Linkfluence. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
90
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |