about summary refs log tree commit homepage
path: root/t/git-http-backend.psgi
diff options
context:
space:
mode:
Diffstat (limited to 't/git-http-backend.psgi')
-rw-r--r--t/git-http-backend.psgi28
1 files changed, 28 insertions, 0 deletions
diff --git a/t/git-http-backend.psgi b/t/git-http-backend.psgi
new file mode 100644
index 00000000..8cec7d35
--- /dev/null
+++ b/t/git-http-backend.psgi
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -w
+# Copyright (C) 2016 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+use strict;
+use warnings;
+use PublicInbox::GitHTTPBackend;
+use PublicInbox::Git;
+use Plack::Builder;
+use Plack::Request;
+use BSD::Resource qw(getrusage);
+my $git_dir = $ENV{GIANT_GIT_DIR} or die 'GIANT_GIT_DIR not defined in env';
+my $git = PublicInbox::Git->new($git_dir);
+builder {
+        enable 'Chunked' if $ENV{TEST_CHUNK};
+        enable 'Head';
+        sub {
+                my ($env) = @_;
+                my $pr = Plack::Request->new($env);
+                if ($pr->path_info =~ m!\A/(.+)\z!s) {
+                        PublicInbox::GitHTTPBackend::serve($pr, $git, $1);
+                } else {
+                        my $ru = getrusage();
+                        my $b = $ru->maxrss . "\n";
+                        [ 200, [ qw(Content-Type text/plain Content-Length),
+                                 length($b) ], [ $b ] ]
+                }
+        }
+}