aboutsummaryrefslogtreecommitdiff
path: root/template/perl/base-psgi-static.pl
blob: aebf116b3b81a3873ac934699ad2527887c63b2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use strict;
use warnings;
use Plack::Builder;
use Plack::Request;

my $app = sub {
    my $env = shift;
    my $req = Plack::Request->new($env);
    return root($req) if $req->path eq '/';
    [ 404, [ "Content-Type" => "text/plain" ], ["Not Found"] ];
};

sub root {
    my $req = shift;
    my $res = $req->new_response(200);
    $res->content_type('text/html');
    $res->body('hello world');
    $res->finalize();
}

builder {
    enable "Plack::Middleware::Static", path => qr/static/, root => '.';
    $app;
};