File Coverage

blib/lib/HTTP/Throwable/Role/Redirect.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package HTTP::Throwable::Role::Redirect;
2             our $AUTHORITY = 'cpan:STEVAN';
3             $HTTP::Throwable::Role::Redirect::VERSION = '0.027';
4 3     3   1946 use Types::Standard qw(Str);
  3         9  
  3         28  
5              
6 3     3   1753 use Moo::Role;
  3         8  
  3         19  
7              
8             has 'location' => (
9             is => 'ro',
10             isa => Str,
11             required => 1,
12             );
13              
14             around 'build_headers' => sub {
15             my $next = shift;
16             my $self = shift;
17             my $headers = $self->$next( @_ );
18             push @$headers => ('Location' => $self->location);
19              
20             return $headers;
21             };
22              
23 3     3   1241 no Moo::Role; 1;
  3         9  
  3         12  
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 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 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
54              
55             =item *
56              
57             Ricardo Signes
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__