| 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
| |||||||||||
| 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__ | ||||||||||