blib/lib/Plack/App/Redirect.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 100% 37 / 37 CC 2 SCAR 2.2
CC
2
Cov
100%
call
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package Plack::App::Redirect;
2  
3 3 ▶use base qw(Plack::Component);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Plack::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Plack::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Plack::Util::Accessor qw(redirect_url);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $VERSION = 0.02;
12  
13 2 ▶sub call {
Subroutine call: called CC=2 SCAR=6.9
Pod documented
14 2 my ($self, $env) = @_;
15  
16 2 ▶ if (defined $self->redirect_url) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->redirect_url) { } 1 1 2
17 1 my $req = Plack::Request->new($env);
18 1 my $res = Plack::Response->new;
19 1 $res->redirect($self->redirect_url.$req->request_uri, 308);
20 1 return $res->finalize;
21 } else {
22 return [
23 1 404,
24 [
25 'content-type' => 'text/html; charset=utf-8',
26 ],
27 ['No redirect.'],
28 ];
29 }
30 }
31  
32 3 1;
33  
34 __END__
↑ Summary