line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::ProxyPassReverse::SubDir; |
2
|
2
|
|
|
2
|
|
6086
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
2
|
|
|
|
|
18098
|
|
|
2
|
|
|
|
|
17
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub register { |
7
|
1
|
|
|
1
|
1
|
38
|
my ($self, $app, $conf) = @_; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
50
|
|
|
4
|
$conf //= {}; |
10
|
1
|
|
50
|
|
|
8
|
my $header = $conf->{header} // 'X-Forwarded-Host'; |
11
|
1
|
|
|
|
|
2
|
my $value = $conf->{value}; |
12
|
1
|
|
50
|
|
|
8
|
my $depth = $conf->{depth} // 1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$app->hook(before_dispatch => sub { |
15
|
2
|
|
|
2
|
|
13933
|
my $c = shift; |
16
|
|
|
|
|
|
|
|
17
|
2
|
100
|
|
|
|
12
|
if ( defined ( my $v = $c->req->headers->header($header) ) ) { |
18
|
1
|
50
|
33
|
|
|
30
|
return if defined $value and $v ne $value; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
31
|
push @{ $c->req->url->base->path->parts }, |
21
|
1
|
|
|
|
|
2
|
@{ $c->req->url->path->parts }[ 0 .. $depth - 1 ]; |
|
1
|
|
|
|
|
89
|
|
22
|
|
|
|
|
|
|
} |
23
|
1
|
|
|
|
|
9
|
}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
__END__ |