line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::HTTP::Spore::Middleware::Format::JSON; |
2
|
|
|
|
|
|
|
$Net::HTTP::Spore::Middleware::Format::JSON::VERSION = '0.09'; |
3
|
|
|
|
|
|
|
# ABSTRACT: middleware for JSON format |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1612
|
use JSON; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
19
|
|
6
|
2
|
|
|
2
|
|
326
|
use Moose; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
20
|
|
7
|
|
|
|
|
|
|
extends 'Net::HTTP::Spore::Middleware::Format'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has _json_parser => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
isa => 'JSON', |
12
|
|
|
|
|
|
|
lazy => 1, |
13
|
|
|
|
|
|
|
default => sub { JSON->new->utf8(1)->allow_nonref }, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
1
|
29
|
sub encode { $_[0]->_json_parser->encode( $_[1] ); } |
17
|
3
|
|
|
3
|
1
|
120
|
sub decode { $_[0]->_json_parser->decode( $_[1] ); } |
18
|
3
|
|
|
3
|
1
|
25
|
sub accept_type { ( 'Accept' => 'application/json' ) } |
19
|
1
|
|
|
1
|
1
|
5
|
sub content_type { ( 'Content-Type' => 'application/json;' ) } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__END__ |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=pod |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=encoding UTF-8 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Net::HTTP::Spore::Middleware::Format::JSON - middleware for JSON format |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 VERSION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
version 0.09 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $client = Net::HTTP::Spore->new_from_spec('twitter.json'); |
40
|
|
|
|
|
|
|
$client->enable('Format::JSON'); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Net::HTTP::Spore::Middleware::Format::JSON is a simple middleware to handle the JSON format. It will set the appropriate B<Accept> header in your request. If the request method is PUT or POST, the B<Content-Type> header will also be set to JSON. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This middleware will also deserialize content in the response. The deserialized content will be store in the B<body> of the response. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 EXAMPLES |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 AUTHORS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over 4 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Franck Cuny <franck.cuny@gmail.com> |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Ash Berlin <ash@cpan.org> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item * |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Ahmad Fatoum <athreef@cpan.org> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=back |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Linkfluence. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
73
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |