1 package App::SCS::Plugin::Generate::StaticServer;
3 use Module::Runtime qw(use_module);
6 has dir => (is => 'ro', required => 1);
8 has app => (is => 'ro', required => 1);
10 has _dir_handler => (is => 'lazy');
12 sub _build__dir_handler {
14 use_module('Plack::App::File')->new(
19 has _static_handler => (is => 'lazy');
21 sub _build__static_handler {
23 use_module('Plack::App::File')->new(
24 root => $self->app->share_dir->catdir('static')
28 sub dispatch_request {
32 return unless $path =~ s/\/-/\//;
33 App::SCS::Web::redispatch_to("/static/${path}");
35 sub (/static/...) { $self->_static_handler },
36 sub (/favicon + .ico) { $self->_static_handler },
41 my ($self, $env) = @_;
42 my @args = @{$env->{argv}};
43 my $r = use_module('Plack::Runner')->new(
45 app => $self->app->web->to_psgi_app
47 $r->parse_options(@args);
48 $r->set_options(argv => \@args);