-# some servers (Ruby webrick) include scheme://host[:port] here,
-# which confuses CGI.pm when generating self_url.
-# RFC 3875 does not mention REQUEST_URI at all,
-# so nuke it since CGI.pm functions without it.
-delete $ENV{REQUEST_URI};
-$ENV{SCRIPT_NAME} = '' if $NO_SCRIPT_NAME;
-my $req = CGI->new;
-my $ret = PublicInbox::WWW::run($req, $req->request_method);
-binmode STDOUT;
-if (@ARGV && $ARGV[0] eq 'static') {
- print $ret->[2]->[0]; # only show the body
-} else { # CGI
- my ($status, $headers, $body) = @$ret;
- my %codes = (
- 200 => 'OK',
- 301 => 'Moved Permanently',
- 404 => 'Not Found',
- 405 => 'Method Not Allowed',
- 501 => 'Not Implemented',
- );
+my $have_deflater = eval { require Plack::Middleware::Deflater; 1 };
+my $app = builder {
+ if ($have_deflater) {
+ enable 'Deflater',
+ content_type => [ 'text/html', 'text/plain',
+ 'application/atom+xml' ];
+ }
+
+ # Enable to ensure redirects and Atom feed URLs are generated
+ # properly when running behind a reverse proxy server which
+ # sets X-Forwarded-For and X-Forwarded-Proto request headers.
+ # See Plack::Middleware::ReverseProxy documentation for details
+ # enable 'ReverseProxy';