]> Sergey Matveev's repositories - public-inbox.git/blob - t/git-http-backend.psgi
www: drop --subject from "git send-email" instructions
[public-inbox.git] / t / git-http-backend.psgi
1 #!/usr/bin/perl -w
2 # Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict;
5 use warnings;
6 use PublicInbox::GitHTTPBackend;
7 use PublicInbox::Git;
8 use Plack::Builder;
9 use BSD::Resource qw(getrusage);
10 my $git_dir = $ENV{GIANT_GIT_DIR} or die 'GIANT_GIT_DIR not defined in env';
11 my $git = PublicInbox::Git->new($git_dir);
12 builder {
13         enable 'Head';
14         sub {
15                 my ($env) = @_;
16                 if ($env->{PATH_INFO} =~ m!\A/(.+)\z!s) {
17                         PublicInbox::GitHTTPBackend::serve($env, $git, $1);
18                 } else {
19                         my $ru = getrusage();
20                         my $b = $ru->maxrss . "\n";
21                         [ 200, [ qw(Content-Type text/plain Content-Length),
22                                  length($b) ], [ $b ] ]
23                 }
24         }
25 }