File Coverage

blib/lib/HTTP/Throwable/Role/TextBody.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 3 0.0
total 15 18 83.3


line stmt bran cond sub pod time code
1             package HTTP::Throwable::Role::TextBody;
2             our $AUTHORITY = 'cpan:STEVAN';
3             $HTTP::Throwable::Role::TextBody::VERSION = '0.027';
4 5     5   3349 use Moo::Role;
  5         15  
  5         37  
5              
6 86     86 0 398 sub body { $_[0]->text_body }
7              
8             sub body_headers {
9 31     31 0 76 my ($self, $body) = @_;
10              
11             return [
12 31         171 'Content-Type' => 'text/plain',
13             'Content-Length' => length $body,
14             ];
15             }
16              
17 55     55 0 41549 sub as_string { $_[0]->body }
18              
19             requires 'text_body';
20              
21 5     5   2146 no Moo::Role; 1;
  5         24  
  5         26  
22              
23             =pod
24              
25             =encoding UTF-8
26              
27             =head1 NAME
28              
29             HTTP::Throwable::Role::TextBody - an exception with a plaintext body
30              
31             =head1 VERSION
32              
33             version 0.027
34              
35             =head1 OVERVIEW
36              
37             This is a very simple role, implementing the required C, C,
38             and C for L. In turn, it requires that a
39             C method be provided.
40              
41             When an HTTP::Throwable exception uses this role, its PSGI response will have a
42             C content type and will send the result of calling its C
43             method as the response body. It will also stringify to the text body.
44              
45             The role L can be useful to provide a
46             C method that issues the C as the body.
47              
48             =head1 AUTHORS
49              
50             =over 4
51              
52             =item *
53              
54             Stevan Little
55              
56             =item *
57              
58             Ricardo Signes
59              
60             =back
61              
62             =head1 COPYRIGHT AND LICENSE
63              
64             This software is copyright (c) 2011 by Infinity Interactive, Inc.
65              
66             This is free software; you can redistribute it and/or modify it under
67             the same terms as the Perl 5 programming language system itself.
68              
69             =cut
70              
71             __END__