actions plugin
[scpubgit/App-SCS.git] / lib / App / SCS / Plugin / Actions.pm
1 package App::SCS::Plugin::Actions;
2
3 use Module::Runtime qw(use_module);
4 use IO::All;
5 use Moo;
6
7 with 'App::SCS::Role::Plugin';
8
9 has mount_at => (is => 'ro', default => sub { 'actions' });
10
11 has dispatcher => (is => 'lazy', builder => sub {
12   my ($self) = @_;
13   use_module('Plack::App::PSGIBin')->new(
14     root => io->dir($self->app->share_dir)->catdir('actions')
15   );
16 });
17
18 sub page_dispatchers {
19   my ($self) = @_;
20   my $base = $self->mount_at;
21   "/${base}/..." => sub { $self->dispatcher },
22 }
23
24 sub provides_pages {
25   my ($self) = @_;
26   return;
27 }
28
29 1;