| 1 | package HTTP::Throwable::Role::Status::ImATeapot 0.028; | ||
| 2 | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 3 | |||
| 4 | use Types::Standard qw(Bool); | ||
| 5 | |||
| 6 | use Moo::Role; | ||
| 7 | |||
| 8 | with( | ||
| 9 | 'HTTP::Throwable', | ||
| 10 | ); | ||
| 11 | |||
| 12 | has 'short' => (is => 'ro', isa => Bool, default => 0); | ||
| 13 | has 'stout' => (is => 'ro', isa => Bool, default => 0); | ||
| 14 | |||
| 15 | sub default_status_code { 418 } | ||
| 16 | sub default_reason { q{I'm a teapot} } | ||
| 17 | |||
| 18 | my $TEAPOT = <<'END'; | ||
| 19 | ( | ||
| 20 | _ ) ) | ||
| 21 | _,(_)._ (( I'M A LITTLE TEAPOT__X__ | ||
| 22 | ___,(_______). ) | ||
| 23 | ,'__. / \ /\_ | ||
| 24 | /,' / |""| \ / / | ||
| 25 | | | | |__| |,' / | ||
| 26 | \`.| / | ||
| 27 | `. : : / | ||
| 28 | `. :.,' | ||
| 29 | `-.________,-' | ||
| 30 | END | ||
| 31 | |||
| 32 | sub text_body { | ||
| 33 | my $self = shift; | ||
| 34 | my $base = $TEAPOT; | ||
| 35 | my $msg = $self->short && $self->stout ? " SHORT AND STOUT" | ||
| 36 | : $self->short ? " SHORT NOT STOUT" | ||
| 37 | : $self->stout ? " MERELY STOUT" | ||
| 38 | : " WITH A SPOUT"; | ||
| 39 | |||
| 40 | $base =~ s/__X__/$msg/; | ||
| 41 | |||
| 42 | return $base; | ||
| 43 | } | ||
| 44 | |||
| 45 | no Moo::Role; 1; | ||
| 46 | |||
| 47 | =pod | ||
| 48 | |||
| 49 | =encoding UTF-8 | ||
| 50 | |||
| 51 | =head1 NAME | ||
| 52 | |||
| 53 | HTTP::Throwable::Role::Status::ImATeapot - 418 I'm a teapot | ||
| 54 | |||
| 55 | =head1 VERSION | ||
| 56 | |||
| 57 | version 0.028 | ||
| 58 | |||
| 59 | =head1 DESCRIPTION | ||
| 60 | |||
| 61 | This exception provides RFC2324 support, in accordance with section 2.3.3: | ||
| 62 | |||
| 63 | Any attempt to brew coffee with a teapot should result in the error code | ||
| 64 | "418 I'm a teapot". The resulting entity body MAY be short and stout. | ||
| 65 | |||
| 66 | Boolean attributes C<short> and C<stout> are provided, and default to false. | ||
| 67 | |||
| 68 | =head1 PERL VERSION | ||
| 69 | |||
| 70 | This library should run on perls released even a long time ago. It should work | ||
| 71 | on any version of perl released in the last five years. | ||
| 72 | |||
| 73 | Although it may work on older versions of perl, no guarantee is made that the | ||
| 74 | minimum required version will not be increased. The version may be increased | ||
| 75 | for any reason, and there is no promise that patches will be accepted to lower | ||
| 76 | the minimum required perl. | ||
| 77 | |||
| 78 | =head1 AUTHORS | ||
| 79 | |||
| 80 | =over 4 | ||
| 81 | |||
| 82 | =item * | ||
| 83 | |||
| 84 | Stevan Little <stevan.little@iinteractive.com> | ||
| 85 | |||
| 86 | =item * | ||
| 87 | |||
| 88 | Ricardo Signes <cpan@semiotic.systems> | ||
| 89 | |||
| 90 | =back | ||
| 91 | |||
| 92 | =head1 COPYRIGHT AND LICENSE | ||
| 93 | |||
| 94 | This software is copyright (c) 2011 by Infinity Interactive, Inc. | ||
| 95 | |||
| 96 | This is free software; you can redistribute it and/or modify it under | ||
| 97 | the same terms as the Perl 5 programming language system itself. | ||
| 98 | |||
| 99 | =cut | ||
| 100 | |||
| 101 | __END__ |