]> Sergey Matveev's repositories - public-inbox.git/commitdiff
examples/public-inbox.psgi: update with middlewares
authorEric Wong <e@80x24.org>
Thu, 3 Sep 2015 08:19:48 +0000 (08:19 +0000)
committerEric Wong <e@80x24.org>
Thu, 3 Sep 2015 08:19:48 +0000 (08:19 +0000)
HTML, text, and probably Atom feeds should be compressed.

examples/public-inbox.psgi

index 8eb67eb182fb01641565dd0932258760709b366c..04f3329a973816e0ff4ba20f799ce85e29c04725 100644 (file)
@@ -5,9 +5,17 @@
 # Usage: plackup [OPTIONS] /path/to/this/file
 use strict;
 use warnings;
-require PublicInbox::WWW;
-require Plack::Request;
-sub {
-       my $req = Plack::Request->new(@_);
-       PublicInbox::WWW::run($req, $req->method);
-};
+use PublicInbox::WWW;
+PublicInbox::WWW->preload;
+use Plack::Request;
+use Plack::Builder;
+builder {
+       enable "Deflater",
+               content_type => [ 'text/html', 'text/plain',
+                               'application/atom+xml' ];
+       enable "Head";
+       sub {
+               my $req = Plack::Request->new(@_);
+               PublicInbox::WWW::run($req, $req->method);
+       }
+}