]> Sergey Matveev's repositories - public-inbox.git/blob - examples/public-inbox.psgi
dcca3b09a3e1e30b324c32dfb1f5edb876b71184
[public-inbox.git] / examples / public-inbox.psgi
1 #!/usr/bin/perl -w
2 # Copyright (C) 2014-2016 all contributors <meta@public-inbox.org>
3 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-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 # A startup command for development which monitors changes:
7 #       plackup -I lib -o 127.0.0.1 -R lib -r examples/public-inbox.psgi
8 use strict;
9 use warnings;
10 use PublicInbox::WWW;
11 PublicInbox::WWW->preload;
12 use Plack::Request;
13 use Plack::Builder;
14 my $www = PublicInbox::WWW->new;
15 builder {
16         enable 'Chunked';
17         eval {
18                 enable 'Deflater',
19                         content_type => [ qw(
20                                 text/html
21                                 text/plain
22                                 application/atom+xml
23                                 )]
24         };
25         $@ and warn
26 "Plack::Middleware::Deflater missing, bandwidth will be wasted\n";
27
28         # Enable to ensure redirects and Atom feed URLs are generated
29         # properly when running behind a reverse proxy server which
30         # sets X-Forwarded-For and X-Forwarded-Proto request headers.
31         # See Plack::Middleware::ReverseProxy documentation for details
32         eval { enable 'ReverseProxy' };
33         $@ and warn
34 "Plack::Middleware::ReverseProxy missing,\n",
35 "URL generation for redirects may be wrong if behind a reverse proxy\n";
36
37         # Optional: Log timing information for requests to track performance.
38         # Logging to STDOUT is recommended since public-inbox-httpd knows
39         # how to reopen it via SIGUSR1 after log rotation.
40         # enable 'AccessLog::Timed',
41         #       logger => sub { syswrite(STDOUT, $_[0]) },
42         #       format => '%t "%r" %>s %b %D';
43
44         enable 'Head';
45         sub { $www->call(@_) };
46 }