X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=script%2Fpublic-inbox-httpd;h=a4dd809916c5116db301ec30c65f0919a48517ec;hb=7e4bd71efcf3bf61216ec1a7577e33be5f95b8a9;hp=56551eded7e0065fdb5891aef6f3604ad7c719eb;hpb=d883d4a93b23be134038e28f421eafca70c3d838;p=public-inbox.git diff --git a/script/public-inbox-httpd b/script/public-inbox-httpd index 56551ede..a4dd8099 100755 --- a/script/public-inbox-httpd +++ b/script/public-inbox-httpd @@ -1,16 +1,21 @@ #!/usr/bin/perl -w -# Copyright (C) 2016-2018 all contributors +# Copyright (C) 2016-2021 all contributors # License: AGPL-3.0+ # # Standalone HTTP server for public-inbox. use strict; -use warnings; -use Plack::Util; +use v5.10.1; use PublicInbox::Daemon; -use PublicInbox::HTTP; -use PublicInbox::HTTPD; -use Plack::Builder; -my %httpds; +BEGIN { + for (qw(Plack::Builder Plack::Util)) { + eval("require $_") or die "E: Plack is required for $0\n"; + } + Plack::Builder->import; + require PublicInbox::HTTP; + require PublicInbox::HTTPD; +} + +my %httpds; # per-listen-FD mapping for HTTPD->{env}->{SERVER_} my $app; my $refresh = sub { if (@ARGV) { @@ -24,15 +29,6 @@ my $refresh = sub { my $www = PublicInbox::WWW->new; $www->preload; $app = builder { - eval { - enable 'Deflater', - content_type => [ qw( - text/html - text/plain - application/atom+xml - )] - }; - eval { enable 'ReverseProxy' }; $@ and warn "Plack::Middleware::ReverseProxy missing,\n", @@ -42,12 +38,14 @@ my $refresh = sub { sub { $www->call(@_) }; }; } + %httpds = (); # invalidate cache }; PublicInbox::Daemon::run('0.0.0.0:8080', $refresh, - sub ($$$) { # post_accept - my ($client, $addr, $srv) = @_; + sub ($$$) { # Listener->{post_accept} + my ($client, $addr, $srv, $tls_wrap) = @_; my $fd = fileno($srv); - my $h = $httpds{$fd} ||= PublicInbox::HTTPD->new($srv, $app); + my $h = $httpds{$fd} //= + PublicInbox::HTTPD->new($srv, $app, $client); PublicInbox::HTTP->new($client, $addr, $h), });