2 # Copyright (C) 2019 all contributors <meta@public-inbox.org>
3 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
5 # NewsWWW may be used independently of WWW. This can be useful
6 # for mapping HTTP/HTTPS requests to the hostname of an NNTP server
7 # to redirect users to the proper HTTP/HTTPS endpoint for a given
8 # inbox. NewsWWW exists because people (or software) can mishandle
9 # "nntp://" or "news://" URLs as "http://" (or "https://")
12 # plackup -I lib -o 127.0.0.1 -R lib -r examples/newswww.psgi
17 use PublicInbox::NewsWWW;
19 my $newswww = PublicInbox::NewsWWW->new;
21 # Optional, (you may drop the "mount '/'" section below)
22 my $www = PublicInbox::WWW->new;
26 # HTTP/1.1 requests to "Host: news.example.com" will hit this:
27 mount 'http://news.example.com/' => builder {
29 sub { $newswww->call($_[0]) };
32 # rest of requests will hit this (optional) part for the
33 # regular PublicInbox::WWW code:
34 # see comments in examples/public-inbox.psgi for more info:
35 mount '/' => builder {
44 eval { enable 'ReverseProxy' };
46 sub { $www->call($_[0]) }