line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebAPI::HTTP::Throwable::Role::JSONBody; |
2
|
|
|
|
|
|
|
$WebAPI::HTTP::Throwable::Role::JSONBody::VERSION = '0.004001'; |
3
|
2
|
|
|
2
|
|
24435778
|
use Moo::Role; |
|
2
|
|
|
|
|
42189
|
|
|
2
|
|
|
|
|
17
|
|
4
|
|
|
|
|
|
|
|
5
|
0
|
|
|
0
|
0
|
|
sub body { return shift->message } |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub body_headers { |
8
|
0
|
|
|
0
|
0
|
|
my ($self, $body) = @_; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
return [ |
11
|
0
|
|
|
|
|
|
'Content-Type' => 'application/json', |
12
|
|
|
|
|
|
|
'Content-Length' => length $body, |
13
|
|
|
|
|
|
|
]; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
0
|
|
sub as_string { return shift->body } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
1; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__END__ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=pod |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=encoding UTF-8 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
WebAPI::HTTP::Throwable::Role::JSONBody |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 VERSION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
version 0.004001 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 OVERVIEW |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
When an HTTP::Throwable exception uses this role, its PSGI response |
37
|
|
|
|
|
|
|
will have a C<application/json> content type and will send the |
38
|
|
|
|
|
|
|
C<message> attribute as the response body. C<message> should be a |
39
|
|
|
|
|
|
|
valid JSON string. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
WebAPI::HTTP::Throwable::Role::JSONBody - an exception with a JSON body |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 AUTHOR |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Tim Bunce <Tim.Bunce@pobox.com> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Tim Bunce. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
54
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |