]> Sergey Matveev's repositories - public-inbox.git/blob - script/public-inbox.cgi
view: get rid of some unnecessary imports
[public-inbox.git] / script / public-inbox.cgi
1 #!/usr/bin/perl -w
2 # Copyright (C) 2014-2018 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ or later <https://www.gnu.org/licenses/agpl-3.0.txt>
4 #
5 # Enables using PublicInbox::WWW as a CGI script
6 use strict;
7 use warnings;
8 use Plack::Builder;
9 use Plack::Handler::CGI;
10 use PublicInbox::WWW;
11 BEGIN { PublicInbox::WWW->preload if $ENV{MOD_PERL} }
12 my $www = PublicInbox::WWW->new;
13 my $have_deflater = eval { require Plack::Middleware::Deflater; 1 };
14 my $app = builder {
15         if ($have_deflater) {
16                 enable 'Deflater',
17                         content_type => [ 'text/html', 'text/plain',
18                                         'application/atom+xml' ];
19         }
20
21         # Enable to ensure redirects and Atom feed URLs are generated
22         # properly when running behind a reverse proxy server which
23         # sets the X-Forwarded-Proto request header.
24         # See Plack::Middleware::ReverseProxy documentation for details
25         # enable 'ReverseProxy';
26
27         enable 'Head';
28         sub { $www->call(@_) };
29 };
30 Plack::Handler::CGI->new->run($app);