« blib/lib/auto/share/dist/Amon2/flavor/Large/script/admin.pl
↑ Summary
lib/Amon2/Setup/Asset/XSRFTokenJS.pm »
| 1 | %% cascade "Minimum/script/server.pl" | ||
| 2 | |||
| 3 | %% override load_modules -> { | ||
| 4 | use <% $module %>::Web; | ||
| 5 | use Plack::App::File; | ||
| 6 | use Plack::Session::Store::DBI; | ||
| 7 | use DBI; | ||
| 8 | %% } | ||
| 9 | |||
| 10 | %% override app -> { | ||
| 11 | use 5.010_001; | ||
| 12 | |||
| 13 | my $basedir = File::Spec->rel2abs(dirname(__FILE__)); | ||
| 14 | my $app = builder { | ||
| 15 | enable 'Plack::Middleware::Static', | ||
| 16 | path => qr{^(?:/robots\.txt|/favicon\.ico)$}, | ||
| 17 | root => File::Spec->catdir(dirname(__FILE__), '..', 'static', 'web'); | ||
| 18 | enable 'Plack::Middleware::ReverseProxy'; | ||
| 19 | enable 'Plack::Middleware::Session', | ||
| 20 | store => Plack::Session::Store::DBI->new( | ||
| 21 | get_dbh => sub { | ||
| 22 | state $db_config = <% $module %>->config->{DBI} || die "Missing configuration for DBI"; | ||
| 23 | DBI->connect( @$db_config ) | ||
| 24 | or die $DBI::errstr; | ||
| 25 | } | ||
| 26 | ); | ||
| 27 | |||
| 28 | mount '/static/' => Plack::App::File->new(root => File::Spec->catdir($basedir, '..', 'static', 'web'))->to_app(); | ||
| 29 | mount '/' => <% $module %>::Web->to_app(); | ||
| 30 | }; | ||
| 31 | %% } |