line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Charon::Web; |
2
|
|
|
|
|
|
|
$App::Charon::Web::VERSION = '0.001001'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Internal (for now) Plack app behind charon |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
16825
|
use utf8; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
487
|
use Web::Simple; |
|
1
|
|
|
|
|
53109
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
3870
|
use warnings NONFATAL => 'all'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
727
|
use Plack::App::Directory; |
|
1
|
|
|
|
|
76686
|
|
|
1
|
|
|
|
|
30
|
|
10
|
1
|
|
|
1
|
|
6
|
use Plack::App::File; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
384
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has _quit => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
init_arg => 'quit', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has _root => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
default => '.', |
21
|
|
|
|
|
|
|
init_arg => 'root', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has _query_param_auth => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
default => sub { |
27
|
|
|
|
|
|
|
require App::Genpass; |
28
|
|
|
|
|
|
|
[auth => scalar App::Genpass->new->generate] |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
init_arg => 'query_param_auth', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has _show_index => ( |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
default => 1, |
36
|
|
|
|
|
|
|
init_arg => 'show_index', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub BUILDARGS { |
40
|
0
|
|
|
0
|
0
|
|
my ($self, %params) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
$params{query_param_auth} = [split m/=/, $params{query_param_auth}, 2] |
43
|
|
|
|
|
|
|
if exists $params{query_param_auth}; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
\%params |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub dispatch_request { |
49
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
my $server = $self->_show_index |
52
|
|
|
|
|
|
|
? 'Plack::App::Directory' |
53
|
|
|
|
|
|
|
: 'Plack::App::File'; |
54
|
0
|
|
|
|
|
|
my @qpa = @{$self->_query_param_auth}; |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
(@qpa ? ( "?$qpa[0]~" => sub { |
56
|
0
|
|
|
0
|
|
|
my ($self, $value) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
0
|
|
|
|
return [403, ['Content-Type' => 'text/plain'], ['nice try']] |
59
|
|
|
|
|
|
|
if !$value || $value ne $qpa[1]; |
60
|
0
|
|
|
|
|
|
return; |
61
|
|
|
|
|
|
|
}) : ()), |
62
|
0
|
|
|
0
|
|
|
'/quit' => sub { shift->_quit->done(1); [200, [], ''] }, |
|
0
|
|
|
|
|
|
|
63
|
0
|
|
|
0
|
|
|
'/_/...' => sub { $server->new( root => shift->_root ) }, |
64
|
0
|
0
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |