From b07d0796e7178fc23673a99c9f49a1a6721746f8 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 3 Jul 2012 14:18:55 +0900 Subject: add psgi apps. --- template/perl/base-psgi-hello.pl | 7 +++++++ template/perl/base-psgi-static.pl | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 template/perl/base-psgi-hello.pl create mode 100644 template/perl/base-psgi-static.pl (limited to 'template') diff --git a/template/perl/base-psgi-hello.pl b/template/perl/base-psgi-hello.pl new file mode 100644 index 0000000..59576e8 --- /dev/null +++ b/template/perl/base-psgi-hello.pl @@ -0,0 +1,7 @@ +my $handler = sub { + return [ + 200, + [ "Content-Type" => "text/plain", "Content-Length" => 11 ], + [ "Hello World" ], + ]; +}; diff --git a/template/perl/base-psgi-static.pl b/template/perl/base-psgi-static.pl new file mode 100644 index 0000000..aebf116 --- /dev/null +++ b/template/perl/base-psgi-static.pl @@ -0,0 +1,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; +}; -- cgit v1.2.3-54-g00ecf