Created
August 20, 2010 17:42
-
-
Save hdp/540793 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment