line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::ParamExpand; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2309
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
1343
|
use CGI::Expand; |
|
2
|
|
|
|
|
2326
|
|
|
2
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub register |
9
|
|
|
|
|
|
|
{ |
10
|
3
|
|
|
3
|
1
|
4144
|
my ($self, $app, $config) = @_; |
11
|
3
|
|
|
|
|
6
|
my $class = 'Mojolicious::Plugin::ParamExpand::expander'; |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
|
|
7
|
_make_package($class, $config); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$app->hook(before_dispatch => sub { |
16
|
6
|
|
|
6
|
|
40543
|
my $c = shift; |
17
|
6
|
|
|
|
|
10
|
my $hash; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
7
|
eval { $hash = $class->expand_hash($c->req->params->to_hash) }; |
|
6
|
|
|
|
|
28
|
|
20
|
6
|
100
|
|
|
|
2560
|
if($@) { |
21
|
|
|
|
|
|
|
# Mojolicious < 6.0 uses render_exception |
22
|
1
|
50
|
|
|
|
15
|
if($c->can('render_exception')) { |
23
|
0
|
|
|
|
|
0
|
$c->render_exception($@); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
1
|
|
|
|
|
8
|
$c->reply->exception($@); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
3386
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
35
|
$c->param($_ => $hash->{$_}) for keys %$hash; |
33
|
3
|
|
|
|
|
29
|
}); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _make_package |
37
|
|
|
|
|
|
|
{ |
38
|
2
|
|
|
2
|
|
462
|
no strict 'refs'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
246
|
|
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
3
|
|
5
|
my ($class, $config) = @_; |
41
|
3
|
|
|
|
|
4
|
@{"${class}::ISA"} = 'CGI::Expand'; |
|
3
|
|
|
|
|
44
|
|
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
8
|
for(qw|max_array separator|) { |
44
|
6
|
|
|
|
|
9
|
my $val = $config->{$_}; |
45
|
6
|
100
|
|
16
|
|
19
|
*{"${class}::$_"} = sub { $val } if defined $val; |
|
2
|
|
|
|
|
12
|
|
|
16
|
|
|
|
|
1201
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |