public
Created — forked from hdp/app.psgi

  • Download Gist
app.psgi
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# vim: ft=perl:
use strict;
use warnings;
 
use Plack::Builder;
use Plack::App::WrapCGI;
use Plack::App::URLMap;
 
builder {
enable 'Static',
path => qr{^/(images|skins|js)/},
root => './';
my $map = Plack::App::URLMap->new;
my @mount;
for my $cgi (<*.cgi>) {
my $app = eval { Plack::App::WrapCGI->new(script => $cgi)->to_app };
unless ($app) {
warn $@;
next;
}
my $wrapped = sub {
$Bugzilla::_request_cache = {};
Bugzilla::init_page();
my $res = $app->(@_);
Bugzilla::_cleanup();
return $res;
};
push @mount, [ '/' => $wrapped ] if $cgi eq 'index.cgi';
push @mount, [ "/$cgi" => $wrapped ];
}
 
$map->mount(@$_) for @mount;
$map->to_app;
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.