$csp =~ s/\n/; /gr;
}
-my $db;
-
sub add_database {
my $app = $_[0];
sub {
- my ($env) = @_;
- $db //= Gruntmaster::Data->connect($ENV{GRUNTMASTER_DSN} // 'dbi:Pg:');
- $env->{'gruntmaster.dbic'} = $db;
- $app->($env)
+ dbinit $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:' unless db;
+ $app->(@_)
}
}
my $resp = $app->($_[0]);
my $hdrs = Plack::Util::headers($resp->[1]);
$hdrs->set('Content-Security-Policy', CONTENT_SECURITY_POLICY);
+ $hdrs->set('Cache-Control', 'public, max-age=604800') if $_[0]->{PATH_INFO} =~ qr,^/static/,;
$resp->[1] = $hdrs->headers;
$resp;
}
enable_if { $_[0]->{PATH_INFO} eq '/ok' } sub { sub{ [200, [], []] }};
enable 'ContentLength';
enable \&add_headers;
+ enable 'Static', path => qr,^/static/,;
enable 'Log4perl', category => 'plack';
enable \&add_database;
enable '+Plack::App::Gruntmaster::Auth',