about summary refs log tree commit homepage
path: root/lib/PublicInbox/Cgit.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-25 07:50:47 +0000
committerEric Wong <e@80x24.org>2019-12-26 10:48:19 +0000
commita7949988f7f8690c868d2150fe3000fcf6a6d5f4 (patch)
tree71c6782191d29573c4e2b025eb4b6d81deddd7ff /lib/PublicInbox/Cgit.pm
parent3eba4cbd05b348622e772889b06a5994ba69d157 (diff)
downloadpublic-inbox-a7949988f7f8690c868d2150fe3000fcf6a6d5f4.tar.gz
Callers can supply an arg to parse_hdr, now, eliminating the
need for closures to capture local variables.
Diffstat (limited to 'lib/PublicInbox/Cgit.pm')
-rw-r--r--lib/PublicInbox/Cgit.pm12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/PublicInbox/Cgit.pm b/lib/PublicInbox/Cgit.pm
index 353f4162..094f146e 100644
--- a/lib/PublicInbox/Cgit.pm
+++ b/lib/PublicInbox/Cgit.pm
@@ -95,6 +95,12 @@ my @PASS_ENV = qw(
 );
 # XXX: cgit filters may care about more variables...
 
+sub cgit_parse_hdr { # {parse_hdr} for Qspawn
+        my ($r, $bref) = @_;
+        my $res = parse_cgi_headers($r, $bref) or return; # incomplete
+        $res;
+}
+
 sub call {
         my ($self, $env) = @_;
         my $path_info = $env->{PATH_INFO};
@@ -123,11 +129,7 @@ sub call {
         my $rdr = input_prepare($env) or return r(500);
         my $qsp = PublicInbox::Qspawn->new($self->{cmd}, $cgi_env, $rdr);
         my $limiter = $self->{pi_config}->limiter('-cgit');
-        $qsp->psgi_return($env, $limiter, sub {
-                my ($r, $bref) = @_;
-                my $res = parse_cgi_headers($r, $bref) or return; # incomplete
-                $res;
-        });
+        $qsp->psgi_return($env, $limiter, \&cgit_parse_hdr);
 }
 
 1;