]> Sergey Matveev's repositories - public-inbox.git/blobdiff - examples/public-inbox.psgi
update git repo location to https:// using GitHTTPBackend.pm
[public-inbox.git] / examples / public-inbox.psgi
index 4edbf5e369914f3f12334b5aa4afa5f14f5bce4a..a90a2bc3ae7544ebedcc5eb04d64b52750989231 100644 (file)
@@ -11,6 +11,10 @@ use PublicInbox::WWW;
 PublicInbox::WWW->preload;
 use Plack::Builder;
 my $www = PublicInbox::WWW->new;
+
+# share the public-inbox code itself:
+my $src = $ENV{SRC_GIT_DIR}; # '/path/to/public-inbox.git'
+
 builder {
        eval {
                enable 'Deflater',
@@ -40,5 +44,13 @@ builder {
        #       format => '%t "%r" %>s %b %D';
 
        enable 'Head';
-       sub { $www->call(@_) };
+       sub {
+               my ($env) = @_;
+               # share public-inbox.git code!
+               if ($src && $env->{PATH_INFO} =~ m!\A/public-inbox\.git/(.*)!) {
+                       PublicInbox::GitHTTPBackend::serve($env, $src, $1);
+               } else {
+                       $www->call($env);
+               }
+       };
 }