]> Sergey Matveev's repositories - public-inbox.git/blob - examples/public-inbox.psgi
examples/public-inbox.psgi: optional deflater
[public-inbox.git] / examples / public-inbox.psgi
1 #!/usr/bin/perl -w
2 # Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
3 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
4 # Note: this is part of our test suite, update t/plack.t if this changes
5 # Usage: plackup [OPTIONS] /path/to/this/file
6 use strict;
7 use warnings;
8 use PublicInbox::WWW;
9 PublicInbox::WWW->preload;
10 use Plack::Request;
11 use Plack::Builder;
12 my $have_deflater = eval { require Plack::Middleware::Deflater; 1 };
13
14 builder {
15         if ($have_deflater) {
16                 enable "Deflater",
17                         content_type => [ 'text/html', 'text/plain',
18                                         'application/atom+xml' ];
19         }
20         enable "Head";
21         sub {
22                 my $req = Plack::Request->new(@_);
23                 PublicInbox::WWW::run($req, $req->method);
24         }
25 }