| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebAPI::DBIC::Router; |
|
2
|
|
|
|
|
|
|
$WebAPI::DBIC::Router::VERSION = '0.003002'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
4608801
|
use Moo; |
|
|
2
|
|
|
|
|
37190
|
|
|
|
2
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
3335
|
use Carp qw(croak); |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
208
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
506
|
use Path::Router; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Plack::App::Path::Router; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use namespace::clean -except => [qw(meta)]; |
|
12
|
|
|
|
|
|
|
use MooX::StrictConstructor; |
|
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
|
|
|
|
|
|
|
my ($self, %args) = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $path = delete $args{path}; |
|
26
|
|
|
|
|
|
|
my $validations = delete $args{validations} || {}; |
|
27
|
|
|
|
|
|
|
my $defaults = delete $args{defaults} || {}; |
|
28
|
|
|
|
|
|
|
my $target = delete $args{target} or croak "target not specified"; |
|
29
|
|
|
|
|
|
|
croak "Unknown params (@{[ sort keys %args ]})" if %args; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$self->router->add_route($path, |
|
32
|
|
|
|
|
|
|
validations => $validations, |
|
33
|
|
|
|
|
|
|
defaults => $defaults, |
|
34
|
|
|
|
|
|
|
target => $target, |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub to_psgi_app { |
|
40
|
|
|
|
|
|
|
my $self = shift; |
|
41
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
local $SIG{__DIE__}; # https://github.com/timbunce/WebAPI-DBIC/issues/22 |
|
47
|
|
|
|
|
|
|
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.003002 |
|
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 |