]> Sergey Matveev's repositories - public-inbox.git/blob - script/public-inbox.cgi
ee9510c1f012757163076cf8b991af64f78ac6d8
[public-inbox.git] / script / public-inbox.cgi
1 #!/usr/bin/perl -w
2 # Copyright (C) 2014-2016 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::Loader;
9 use Plack::Builder;
10 use Plack::Request;
11 use Plack::Handler::CGI;
12 use PublicInbox::WWW;
13 BEGIN { PublicInbox::WWW->preload if $ENV{MOD_PERL} }
14 my $www = PublicInbox::WWW->new;
15 my $have_deflater = eval { require Plack::Middleware::Deflater; 1 };
16 my $app = builder {
17         if ($have_deflater) {
18                 enable 'Deflater',
19                         content_type => [ 'text/html', 'text/plain',
20                                         'application/atom+xml' ];
21         }
22
23         # Enable to ensure redirects and Atom feed URLs are generated
24         # properly when running behind a reverse proxy server which
25         # sets X-Forwarded-For and X-Forwarded-Proto request headers.
26         # See Plack::Middleware::ReverseProxy documentation for details
27         # enable 'ReverseProxy';
28
29         enable 'Head';
30         sub { $www->call(@_) };
31 };
32 Plack::Handler::CGI->new->run($app);