From a55a38db0276a8ce1a09392573af6e1305cbaba9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 1 Aug 2022 21:24:42 +0000 Subject: httpd: make internals slightly more generic This brings the HTTP server closer to the IMAP/NNTP/POP3 implementations and eliminates package-wide globals in PublicInbox::HTTPD. The end goal is to be able to host completely different PSGI applications on different listen ports. --- lib/PublicInbox/Daemon.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/PublicInbox/Daemon.pm') diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index bceae6e5..1af03cc4 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -81,11 +81,11 @@ sub load_mod ($) { my $mod = $modc.'D'; eval "require $mod"; # IMAPD|HTTPD|NNTPD|POP3D die $@ if $@; - my %xn = map { $_ => $mod->can($_) } qw(refresh post_accept); - $xn{tlsd} = $mod->new if $mod->can('refresh_groups'); #!HTTPD - my $tlsd = $xn{tlsd}; - $xn{refresh} //= sub { $tlsd->refresh_groups(@_) }; - $xn{post_accept} //= sub { $modc->new($_[0], $tlsd) }; + my %xn; + my $tlsd = $xn{tlsd} = $mod->new; + $xn{refresh} = sub { $tlsd->refresh_groups(@_) }; + $xn{post_accept} = $tlsd->can('post_accept_cb') ? + $tlsd->post_accept_cb : sub { $modc->new($_[0], $tlsd) }; $xn{af_default} = 'httpready' if $modc eq 'PublicInbox::HTTP'; \%xn; } -- cgit v1.2.3-24-ge0c7