aboutsummaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2012-07-03 14:18:55 +0900
committermattn <mattn.jp@gmail.com>2012-07-03 14:20:35 +0900
commitb07d0796e7178fc23673a99c9f49a1a6721746f8 (patch)
tree63c366c385ea3a506a1a517379ed1ff598b3eeb3 /template
parentd05c908eec1e0fffe1ee20d3419cc0e382162bbf (diff)
downloadvim-sonictemplate-b07d0796e7178fc23673a99c9f49a1a6721746f8.tar.gz
vim-sonictemplate-b07d0796e7178fc23673a99c9f49a1a6721746f8.tar.bz2
vim-sonictemplate-b07d0796e7178fc23673a99c9f49a1a6721746f8.zip
add psgi apps.
Diffstat (limited to 'template')
-rw-r--r--template/perl/base-psgi-hello.pl7
-rw-r--r--template/perl/base-psgi-static.pl24
2 files changed, 31 insertions, 0 deletions
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;
+};