| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Router::Simple::Sinatraish; |
|
2
|
2
|
|
|
2
|
|
448347
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
93
|
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
79
|
|
|
4
|
2
|
|
|
2
|
|
2144
|
use parent qw/Exporter/; |
|
|
2
|
|
|
|
|
828
|
|
|
|
2
|
|
|
|
|
13
|
|
|
5
|
2
|
|
|
2
|
|
204
|
use 5.00800; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
156
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
7
|
2
|
|
|
2
|
|
1866
|
use Router::Simple; |
|
|
2
|
|
|
|
|
13784
|
|
|
|
2
|
|
|
|
|
134
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/router any get post/; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub router { |
|
12
|
10
|
|
|
10
|
1
|
2382
|
my $class = shift; |
|
13
|
2
|
|
|
2
|
|
23
|
no strict 'refs'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
66
|
|
|
14
|
2
|
|
|
2
|
|
11
|
no warnings 'once'; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
645
|
|
|
15
|
10
|
|
66
|
|
|
12
|
${"${class}::ROUTER"} ||= Router::Simple->new(); |
|
|
10
|
|
|
|
|
156
|
|
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# any [qw/get post delete/] => '/bye' => sub { ... }; |
|
19
|
|
|
|
|
|
|
# any '/bye' => sub { ... }; |
|
20
|
|
|
|
|
|
|
sub any($$;$) { |
|
21
|
2
|
|
|
2
|
1
|
103
|
my $pkg = caller(0); |
|
22
|
2
|
100
|
|
|
|
7
|
if (@_==3) { |
|
23
|
1
|
|
|
|
|
3
|
my ($methods, $pattern, $code) = @_; |
|
24
|
1
|
|
|
|
|
18
|
$pkg->router->connect( |
|
25
|
|
|
|
|
|
|
$pattern, |
|
26
|
|
|
|
|
|
|
{code => $code}, |
|
27
|
1
|
|
|
|
|
3
|
{ method => [ map { uc $_ } @$methods ] } |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
} else { |
|
30
|
1
|
|
|
|
|
2
|
my ($pattern, $code) = @_; |
|
31
|
1
|
|
|
|
|
3
|
$pkg->router->connect( |
|
32
|
|
|
|
|
|
|
$pattern, |
|
33
|
|
|
|
|
|
|
{code => $code}, |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get { |
|
39
|
1
|
|
|
1
|
1
|
13
|
my $pkg = caller(0); |
|
40
|
1
|
|
|
|
|
8
|
$pkg->router->connect($_[0], {code => $_[1]}, {method => ['GET', 'HEAD']}); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
sub post { |
|
43
|
1
|
|
|
1
|
1
|
124
|
my $pkg = caller(0); |
|
44
|
1
|
|
|
|
|
4
|
$pkg->router->connect($_[0], {code => $_[1]}, {method => ['POST']}); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
|
48
|
|
|
|
|
|
|
__END__ |