]> Sergey Matveev's repositories - public-inbox.git/blob - examples/public-inbox.psgi
examples/public-inbox.psgi: add note for our httpd
[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::Builder;
13 my $www = PublicInbox::WWW->new;
14 builder {
15         # Chunked middleware conflicts with Starman:
16         # https://github.com/miyagawa/Starman/issues/23
17         # However, it is strongly recommended to enable it if using
18         # public-inbox-httpd to allow persistent connections
19         # enable 'Chunked';
20         eval {
21                 enable 'Deflater',
22                         content_type => [ qw(
23                                 text/html
24                                 text/plain
25                                 application/atom+xml
26                                 )]
27         };
28         $@ and warn
29 "Plack::Middleware::Deflater missing, bandwidth will be wasted\n";
30
31         # Enable to ensure redirects and Atom feed URLs are generated
32         # properly when running behind a reverse proxy server which
33         # sets X-Forwarded-For and X-Forwarded-Proto request headers.
34         # See Plack::Middleware::ReverseProxy documentation for details
35         eval { enable 'ReverseProxy' };
36         $@ and warn
37 "Plack::Middleware::ReverseProxy missing,\n",
38 "URL generation for redirects may be wrong if behind a reverse proxy\n";
39
40         # Optional: Log timing information for requests to track performance.
41         # Logging to STDOUT is recommended since public-inbox-httpd knows
42         # how to reopen it via SIGUSR1 after log rotation.
43         # enable 'AccessLog::Timed',
44         #       logger => sub { syswrite(STDOUT, $_[0]) },
45         #       format => '%t "%r" %>s %b %D';
46
47         enable 'Head';
48         sub { $www->call(@_) };
49 }