]> Sergey Matveev's repositories - public-inbox.git/commitdiff
examples/public-inbox.psgi: optional deflater
authorEric Wong <e@80x24.org>
Fri, 11 Sep 2015 05:42:40 +0000 (05:42 +0000)
committerEric Wong <e@80x24.org>
Fri, 11 Sep 2015 05:42:40 +0000 (05:42 +0000)
The deflater middleware isn't standard Plack, so don't require
potential users install it.

examples/public-inbox.psgi

index 1de5bb7daec73120aa1502905dd2559b2c6cbb26..b0b9ae9850bd9620937a15dff753df152588d0df 100644 (file)
@@ -9,10 +9,14 @@ use PublicInbox::WWW;
 PublicInbox::WWW->preload;
 use Plack::Request;
 use Plack::Builder;
+my $have_deflater = eval { require Plack::Middleware::Deflater; 1 };
+
 builder {
-       enable "Deflater",
-               content_type => [ 'text/html', 'text/plain',
-                               'application/atom+xml' ];
+       if ($have_deflater) {
+               enable "Deflater",
+                       content_type => [ 'text/html', 'text/plain',
+                                       'application/atom+xml' ];
+       }
        enable "Head";
        sub {
                my $req = Plack::Request->new(@_);