1 package App::SCS::Plugin::Server;
3 use Module::Runtime qw(use_module);
5 no warnings::illegalproto;
7 with 'App::SCS::Role::Plugin';
9 has _static_handler => (is => 'lazy');
11 sub _build__static_handler {
13 use_module('Plack::App::File')->new(
14 root => $self->app->share_dir->catdir('static')
18 sub page_dispatchers {
22 return unless $path =~ s/(?=\/|^)-//;
23 App::SCS::Web::redispatch_to("/static/${path}");
25 sub (/static/...) { $self->_static_handler },
26 sub (/favicon + .ico) { $self->_static_handler },
29 sub run_command_server {
30 my ($self, $env) = @_;
31 my @args = @{$env->{argv}};
32 my $r = use_module('Plack::Runner')->new(
34 app => $self->app->web->to_psgi_app
36 $r->parse_options(@args);
37 $r->set_options(argv => \@args);