line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PAD; |
2
|
1
|
|
|
1
|
|
23413
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
5
|
1
|
|
|
1
|
|
647
|
use Plack::Request; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
968
|
use Plack::App::Directory; |
|
1
|
|
|
|
|
19079
|
|
|
1
|
|
|
|
|
424
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
0
|
|
my ($class, %args) = @_; |
10
|
0
|
|
|
|
|
|
my $plugin = $args{plugin}; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
__PACKAGE__->require($plugin); |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
bless { |
15
|
|
|
|
|
|
|
plugin => $plugin, |
16
|
|
|
|
|
|
|
args => \%args, |
17
|
|
|
|
|
|
|
}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
0
|
|
sub plugin { shift->{plugin} } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub psgi_app { |
23
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return sub { |
26
|
0
|
|
|
0
|
|
|
my $req = Plack::Request->new(shift); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $path = $req->path_info; |
29
|
0
|
|
|
|
|
|
$path =~ s/[\/\\\0]//g; |
30
|
0
|
0
|
0
|
|
|
|
if ($path eq '/' || $path eq 'favicon.ico' || not $path) { |
|
|
|
0
|
|
|
|
|
31
|
0
|
|
|
|
|
|
return Plack::App::Directory->new->to_app->($req->env); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $plugin = $self->plugin->new( |
35
|
0
|
|
|
|
|
|
%{ $self->{args} }, |
36
|
|
|
|
|
|
|
request => $req, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
return $req->path_info =~ $plugin->suffix |
40
|
|
|
|
|
|
|
? $plugin->execute |
41
|
|
|
|
|
|
|
: Plack::App::Directory->new->to_app->($req->env); |
42
|
0
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub require { |
46
|
0
|
|
|
0
|
0
|
|
my (undef, $class) = @_; |
47
|
0
|
0
|
|
|
|
|
unless ($class->can("new")) { |
48
|
0
|
|
|
|
|
|
my $path = $class; |
49
|
0
|
|
|
|
|
|
$path =~ s|::|/|g; |
50
|
0
|
|
|
|
|
|
require "$path.pm"; ## no critic |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
__END__ |