App-Netdisco
view release on metacpan or search on metacpan
bin/netdisco-web-fg view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
BEGIN {
if ($ENV{_} and $ENV{_} =~ m/netdisco-web-fg$/) {
die "You probably want: '~/bin/localenv starman $0 --workers=1 --disable-keepalive'\n";
}
}
use FindBin;
FindBin::again();
use Path::Class 'dir';
BEGIN {
# stuff useful locations into @INC
unshift @INC,
dir($FindBin::RealBin)->parent->subdir('lib')->stringify,
dir($FindBin::RealBin, 'lib')->stringify;
unshift @INC,
split m/:/, ($ENV{NETDISCO_INC} || '');
}
use App::Netdisco;
use Dancer;
BEGIN {
warning sprintf "App::Netdisco %s web", ($App::Netdisco::VERSION || 'HEAD');
}
# Exact strings, not patterns: Deflater compares with `eq`, where the Expires
# filter below takes regexes. text/xml is what Dancer::Plugin::Ajax gives the
# ajax fragments. Both JavaScript spellings appear because Plack::MIME has
# served .js as each.
my @compressible = qw(
text/html
text/xml
text/css
text/javascript
application/javascript
text/plain
application/json
image/svg+xml
);
set plack_middlewares => [
['Plack::Middleware::ReverseProxy'],
# Above Static, which short-circuits: below it, static assets never compress.
( setting('compress_responses')
? [ Deflater => ( content_type => \@compressible ) ]
: () ),
[ Headers => (
set => ['X-Frame-Options' => setting('HTTP-Header-X-Frame-Options')],
)],
[ Headers => (
set => ['Content-Security-Policy' => setting('HTTP-Header-Content-Security-Policy')],
)],
[ Expires => (
content_type => [qr{^application/javascript}, qr{^text/javascript},
qr{^text/css}, qr{image}, qr{font}],
expires => 'access plus 1 day',
)],
[ Static => (
path => qr{^/(?:javascripts|css|font|images)/},
root => $ENV{DANCER_PUBLIC},
pass_through => 1,
)],
( run in 0.467 second using v1.01-cache-2.11-cpan-302cb4679cc )