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