line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::App::Redirect; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
84827
|
use base qw(Plack::Component); |
|
3
|
|
|
|
|
23
|
|
|
3
|
|
|
|
|
1262
|
|
4
|
3
|
|
|
3
|
|
31546
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
119
|
|
5
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
74
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1239
|
use Plack::Response; |
|
3
|
|
|
|
|
28791
|
|
|
3
|
|
|
|
|
83
|
|
8
|
3
|
|
|
3
|
|
1474
|
use Plack::Request; |
|
3
|
|
|
|
|
163030
|
|
|
3
|
|
|
|
|
104
|
|
9
|
3
|
|
|
3
|
|
28
|
use Plack::Util::Accessor qw(redirect_url); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
24
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.02; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub call { |
14
|
2
|
|
|
2
|
1
|
24131
|
my ($self, $env) = @_; |
15
|
|
|
|
|
|
|
|
16
|
2
|
100
|
|
|
|
11
|
if (defined $self->redirect_url) { |
17
|
1
|
|
|
|
|
14
|
my $req = Plack::Request->new($env); |
18
|
1
|
|
|
|
|
20
|
my $res = Plack::Response->new; |
19
|
1
|
|
|
|
|
14
|
$res->redirect($self->redirect_url.$req->request_uri, 308); |
20
|
1
|
|
|
|
|
148
|
return $res->finalize; |
21
|
|
|
|
|
|
|
} else { |
22
|
|
|
|
|
|
|
return [ |
23
|
1
|
|
|
|
|
19
|
404, |
24
|
|
|
|
|
|
|
[ |
25
|
|
|
|
|
|
|
'content-type' => 'text/html; charset=utf-8', |
26
|
|
|
|
|
|
|
], |
27
|
|
|
|
|
|
|
['No redirect.'], |
28
|
|
|
|
|
|
|
]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |