line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Articulate::Syntax::Routes; |
2
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
132
|
|
3
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
101
|
|
4
|
|
|
|
|
|
|
# use Dancer qw(:syntax); |
5
|
4
|
|
|
4
|
|
22
|
use Exporter::Declare; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
33
|
|
6
|
4
|
|
|
4
|
|
5638
|
use Articulate::Service; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
29
|
|
7
|
|
|
|
|
|
|
default_exports qw( |
8
|
|
|
|
|
|
|
any get post patch del put options |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
# request upload uploads captures param params splat |
11
|
|
|
|
|
|
|
# config var session template |
12
|
|
|
|
|
|
|
# redirect forward halt pass send_error status |
13
|
|
|
|
|
|
|
# ); # the first line will stay, everything else will find its way into framework |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
1338
|
no warnings 'redefine'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
385
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub on_enable { |
18
|
36
|
|
|
36
|
0
|
46
|
my $code = shift; |
19
|
36
|
|
|
|
|
122
|
my ($pkg) = caller(2); |
20
|
36
|
|
|
|
|
205
|
my $routes = "${pkg}::__routes"; |
21
|
|
|
|
|
|
|
{ |
22
|
4
|
|
|
4
|
|
24
|
no strict 'refs'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
1314
|
|
|
36
|
|
|
|
|
29
|
|
23
|
36
|
|
100
|
|
|
185
|
$$routes //= []; |
24
|
36
|
|
|
|
|
156
|
push @$$routes, $code; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _declare_route { |
29
|
36
|
|
|
36
|
|
55
|
my ( $http_verb, $path, $code ) = @_; |
30
|
|
|
|
|
|
|
on_enable ( sub { |
31
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
32
|
0
|
|
|
|
|
0
|
my $wrapped = sub{ $self->serialisation->serialise( $code->( @_ ) ) }; |
|
0
|
|
|
|
|
0
|
|
33
|
0
|
|
|
|
|
0
|
$self->framework->declare_route( $http_verb => $path => sub { perform_request( $wrapped, [ $self, $self->framework->request ] ) } ); |
|
0
|
|
|
|
|
0
|
|
34
|
36
|
|
|
|
|
147
|
} ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
0
|
0
|
sub any { _declare_route ( any => @_ ); } |
38
|
12
|
|
|
12
|
0
|
52
|
sub get { _declare_route ( get => @_ ); } |
39
|
24
|
|
|
24
|
0
|
53
|
sub post { _declare_route ( post => @_ ); } |
40
|
0
|
|
|
0
|
0
|
|
sub patch { _declare_route ( patch => @_ ); } |
41
|
0
|
|
|
0
|
0
|
|
sub del { _declare_route ( del => @_ ); } |
42
|
0
|
|
|
0
|
0
|
|
sub put { _declare_route ( put => @_ ); } |
43
|
0
|
|
|
0
|
0
|
|
sub options { _declare_route ( options => @_ ); } |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub perform_request { |
47
|
0
|
|
|
0
|
0
|
|
$_[0]->(@{ $_[1] }); |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |