File Coverage

blib/lib/KelpX/Symbiosis/Engine/URLMap.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 6 6 100.0
pod 3 3 100.0
total 29 30 96.6


line stmt bran cond sub pod time code
1             package KelpX::Symbiosis::Engine::URLMap;
2             $KelpX::Symbiosis::Engine::URLMap::VERSION = '2.11';
3 7     7   4312 use Kelp::Base 'KelpX::Symbiosis::Engine';
  7         14  
  7         47  
4 7     7   4939 use Plack::App::URLMap;
  7         8398  
  7         237  
5 7     7   46 use Carp;
  7         15  
  7         2040  
6              
7             attr handler => sub { Plack::App::URLMap->new };
8              
9             sub build
10             {
11 7     7 1 54 my ($self, %args) = @_;
12              
13             # even if not mounted, try to mount under /
14             $args{mount} //= '/'
15 7 100 50     34 unless exists $args{mount};
16              
17 7         40 $self->SUPER::build(%args);
18             }
19              
20             sub mount
21             {
22 18     18 1 155 my ($self, $path, $app) = @_;
23              
24 18         51 $self->handler->map($path, $self->run_app($app));
25 18         900 return;
26             }
27              
28             sub run
29             {
30 24     24 1 232 my $self = shift;
31              
32 24         84 return $self->handler->to_app;
33             }
34              
35             1;
36             __END__
37              
38             =head1 NAME
39              
40             KelpX::Symbiosis::Engine::URLMap - Default engine implementation
41              
42             =head1 DESCRIPTION
43              
44             This is a reimplementation of L<KelpX::Symbiosis::Engine> using
45             L<Plack::App::URLMap> as a runner. It's pretty straightforward and mounts Kelp
46             as just one of the apps in the ecosystem (not giving it any special treatment).
47              
48             =head1 CAVEATS
49              
50             =head2 Symbiosis paths will always have priority over Kelp routes
51