From: Eric Wong Date: Mon, 7 Mar 2016 08:10:56 +0000 (+0000) Subject: repobrowse: standardize interface a bit X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2de5a44d184c25b162229690282a237adadbcb55;p=thirdparty%2Fpublic-inbox.git repobrowse: standardize interface a bit Make it closer to what the existing WWW interface is since we no longer rely on CGI.pm --- diff --git a/examples/repobrowse.psgi b/examples/repobrowse.psgi index a642911fe..6e7a591b9 100644 --- a/examples/repobrowse.psgi +++ b/examples/repobrowse.psgi @@ -6,7 +6,6 @@ use strict; use warnings; use PublicInbox::Repobrowse; -use Plack::Request; use Plack::Builder; my $have_deflater = eval { require Plack::Middleware::Deflater; 1 }; my $repo_browse = PublicInbox::Repobrowse->new; @@ -19,8 +18,5 @@ builder { 'application/atom+xml' ]; } enable 'Head'; - sub { - my $req = Plack::Request->new(@_); - $repo_browse->run($req, $req->method); - } + sub { $repo_browse->call(@_) } } diff --git a/lib/PublicInbox/Repobrowse.pm b/lib/PublicInbox/Repobrowse.pm index 51ec14c8e..fe06a5bef 100644 --- a/lib/PublicInbox/Repobrowse.pm +++ b/lib/PublicInbox/Repobrowse.pm @@ -20,6 +20,7 @@ package PublicInbox::Repobrowse; use strict; use warnings; +use Plack::Request; use URI::Escape qw(uri_escape_utf8 uri_unescape); use PublicInbox::RepobrowseConfig; @@ -66,8 +67,10 @@ sub root_index { $mod->new->call($self->{rconfig}); # RepobrowseRoot::call } -sub run { - my ($self, $cgi, $method) = @_; +sub call { + my ($self, $env) = @_; + my $cgi = Plack::Request->new($env); + my $method = $cgi->method; return r(405, 'Method Not Allowed') if ($method !~ /\AGET|HEAD|POST\z/); # URL syntax: / repo [ / cmd [ / path ] ]