line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::Conditional; |
2
|
30
|
|
|
30
|
|
177
|
use strict; |
|
30
|
|
|
|
|
49
|
|
|
30
|
|
|
|
|
851
|
|
3
|
30
|
|
|
30
|
|
127
|
use parent qw(Plack::Middleware); |
|
30
|
|
|
|
|
41
|
|
|
30
|
|
|
|
|
133
|
|
4
|
|
|
|
|
|
|
|
5
|
30
|
|
|
30
|
|
1157
|
use Plack::Util::Accessor qw( condition middleware builder ); |
|
30
|
|
|
|
|
46
|
|
|
30
|
|
|
|
|
98
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub prepare_app { |
8
|
5
|
|
|
5
|
1
|
8
|
my $self = shift; |
9
|
5
|
|
|
|
|
17
|
$self->middleware( $self->builder->($self->app) ); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub call { |
13
|
13
|
|
|
13
|
1
|
26
|
my($self, $env) = @_; |
14
|
|
|
|
|
|
|
|
15
|
13
|
100
|
|
|
|
31
|
my $app = $self->condition->($env) ? $self->middleware : $self->app; |
16
|
13
|
|
|
|
|
40
|
return $app->($env); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__END__ |