line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebAPI::DBIC::Router; |
2
|
|
|
|
|
|
|
$WebAPI::DBIC::Router::VERSION = '0.004001'; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
7243722
|
use Moo; |
|
2
|
|
|
|
|
33661
|
|
|
2
|
|
|
|
|
2956
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
3969
|
use Carp qw(croak); |
|
2
|
|
|
|
|
20
|
|
|
2
|
|
|
|
|
173
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1235
|
use Path::Router; |
|
2
|
|
|
|
|
1998921
|
|
|
2
|
|
|
|
|
22
|
|
9
|
2
|
|
|
2
|
|
1327
|
use Plack::App::Path::Router; |
|
2
|
|
|
|
|
474483
|
|
|
2
|
|
|
|
|
27
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
105
|
use namespace::clean -except => [qw(meta)]; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
25
|
|
12
|
2
|
|
|
2
|
|
1614
|
use MooX::StrictConstructor; |
|
2
|
|
|
|
|
21047
|
|
|
2
|
|
|
|
|
11
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has router => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
default => sub { Path::Router->new }, |
18
|
|
|
|
|
|
|
handles => [ qw(match) ], |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub add_route { |
23
|
0
|
|
|
0
|
0
|
|
my ($self, %args) = @_; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $path = delete $args{path}; |
26
|
0
|
|
0
|
|
|
|
my $validations = delete $args{validations} || {}; |
27
|
0
|
|
0
|
|
|
|
my $defaults = delete $args{defaults} || {}; |
28
|
0
|
0
|
|
|
|
|
my $target = delete $args{target} or croak "target not specified"; |
29
|
0
|
0
|
|
|
|
|
croak "Unknown params (@{[ sort keys %args ]})" if %args; |
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$self->router->add_route($path, |
32
|
|
|
|
|
|
|
validations => $validations, |
33
|
|
|
|
|
|
|
defaults => $defaults, |
34
|
|
|
|
|
|
|
target => $target, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub to_psgi_app { |
40
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
41
|
0
|
|
|
|
|
|
return Plack::App::Path::Router->new( router => $self->router )->to_app; # return Plack app |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub uri_for { # called by WebAPI::DBIC::Resource::Role::Router |
46
|
0
|
|
|
0
|
0
|
|
local $SIG{__DIE__}; # https://github.com/timbunce/WebAPI-DBIC/issues/22 |
47
|
0
|
|
|
|
|
|
return shift->router->uri_for(@_); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding UTF-8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
WebAPI::DBIC::Router |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
version 0.004001 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This is currently a wrapper for L<Path::Router>. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The intention is to allow support for other routers. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
WebAPI::DBIC::Router - Route URL paths to resources |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Tim Bunce <Tim.Bunce@pobox.com> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Tim Bunce. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
86
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |