Add /static to PSGI app for easier testing

This commit is contained in:
Maximilian Gass 2011-05-30 09:53:09 +02:00
parent 2939e65214
commit 80e5249d54
1 changed files with 13 additions and 9 deletions

View File

@ -5,6 +5,7 @@ use warnings;
use Data::Random qw(rand_enum);
use Plack::App::File;
use Plack::Builder;
use YAML::XS qw(LoadFile);
use Template;
@ -38,13 +39,16 @@ sub generate_genre {
return join ' ', map { ucfirst } @genre;
}
my $app = sub {
my $genre = generate_genre();
my $out = '';
$template->process('index.tt', { genre => $genre }, \$out);
return [
200,
[ 'Content-Type' => 'text/html' ],
[ $out ]
];
builder {
mount '/static' => Plack::App::File->new(root => 'static')->to_app(),
mount '/' => sub {
my $genre = generate_genre();
my $out = '';
$template->process('index.tt', { genre => $genre }, \$out);
return [
200,
[ 'Content-Type' => 'text/html' ],
[ $out ]
];
},
}