| 1 | package HTTP::Throwable::Role::TextBody; | ||
| 2 | 5 | our $AUTHORITY = 'cpan:STEVAN'; | |
| 3 | 5 | $HTTP::Throwable::Role::TextBody::VERSION = '0.027'; | |
| 4 | 5 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 86 | ▶ | sub body { $_[0]->text_body } |
|
Subroutine
body: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 7 | |||
| 8 | sub body_headers { | ||
| 9 | 31 | ▶ | my ($self, $body) = @_; |
|
Subroutine
body_headers: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 10 | |||
| 11 | return [ | ||
| 12 | 31 | 'Content-Type' => 'text/plain', | |
| 13 | 'Content-Length' => length $body, | ||
| 14 | ]; | ||
| 15 | } | ||
| 16 | |||
| 17 | 55 | ▶ | sub as_string { $_[0]->body } |
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 18 | |||
| 19 | 5 | requires 'text_body'; | |
| 20 | |||
| 21 | 5 | ▶ | no Moo::Role; 1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 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<as_string>, C<body>, | ||
| 38 | and C<body_headers> for L<HTTP::Throwable>. In turn, it requires that a | ||
| 39 | C<text_body> method be provided. | ||
| 40 | |||
| 41 | When an HTTP::Throwable exception uses this role, its PSGI response will have a | ||
| 42 | C<text/plain> content type and will send the result of calling its C<text_body> | ||
| 43 | method as the response body. It will also stringify to the text body. | ||
| 44 | |||
| 45 | The role L<HTTP::Throwable::Role::BoringText> can be useful to provide a | ||
| 46 | C<text_body> method that issues the C<status_line> as the body. | ||
| 47 | |||
| 48 | =head1 AUTHORS | ||
| 49 | |||
| 50 | =over 4 | ||
| 51 | |||
| 52 | =item * | ||
| 53 | |||
| 54 | Stevan Little <stevan.little@iinteractive.com> | ||
| 55 | |||
| 56 | =item * | ||
| 57 | |||
| 58 | Ricardo Signes <rjbs@cpan.org> | ||
| 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__ | ||