| 1 | package HTTP::Throwable::Role::Redirect; | ||
| 2 | 3 | our $AUTHORITY = 'cpan:STEVAN'; | |
| 3 | 3 | $HTTP::Throwable::Role::Redirect::VERSION = '0.027'; | |
| 4 | 3 | ▶ | use Types::Standard qw(Str); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 3 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 3 | has 'location' => ( | |
| 9 | is => 'ro', | ||
| 10 | isa => Str, | ||
| 11 | required => 1, | ||
| 12 | ); | ||
| 13 | |||
| 14 | around 'build_headers' => sub { | ||
| 15 | 13 | ▶ | my $next = shift; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 16 | 13 | my $self = shift; | |
| 17 | 13 | my $headers = $self->$next( @_ ); | |
| 18 | 13 | push @$headers => ('Location' => $self->location); | |
| 19 | |||
| 20 | 13 | return $headers; | |
| 21 | 3 | }; | |
| 22 | |||
| 23 | 3 | ▶ | no Moo::Role; 1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | =pod | ||
| 26 | |||
| 27 | =encoding UTF-8 | ||
| 28 | |||
| 29 | =head1 NAME | ||
| 30 | |||
| 31 | HTTP::Throwable::Role::Redirect - an exception that is a redirect | ||
| 32 | |||
| 33 | =head1 VERSION | ||
| 34 | |||
| 35 | version 0.027 | ||
| 36 | |||
| 37 | =head1 OVERVIEW | ||
| 38 | |||
| 39 | This is an extremely simple method used by most of the 3xx series of | ||
| 40 | exceptions. It adds a C<location> attribute that will be provided as the | ||
| 41 | Location header when the exception is converted to an HTTP message. | ||
| 42 | |||
| 43 | Note that "MultipleChoices," the 300 status code is I<not> currently a | ||
| 44 | redirect, as its Location header is optional. This may change in the future of | ||
| 45 | the semantics of this role are refined. | ||
| 46 | |||
| 47 | =head1 AUTHORS | ||
| 48 | |||
| 49 | =over 4 | ||
| 50 | |||
| 51 | =item * | ||
| 52 | |||
| 53 | Stevan Little <stevan.little@iinteractive.com> | ||
| 54 | |||
| 55 | =item * | ||
| 56 | |||
| 57 | Ricardo Signes <rjbs@cpan.org> | ||
| 58 | |||
| 59 | =back | ||
| 60 | |||
| 61 | =head1 COPYRIGHT AND LICENSE | ||
| 62 | |||
| 63 | This software is copyright (c) 2011 by Infinity Interactive, Inc. | ||
| 64 | |||
| 65 | This is free software; you can redistribute it and/or modify it under | ||
| 66 | the same terms as the Perl 5 programming language system itself. | ||
| 67 | |||
| 68 | =cut | ||
| 69 | |||
| 70 | __END__ | ||