aboutsummaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
Diffstat (limited to 'perl')
-rwxr-xr-xperl/cgi.pl12
-rwxr-xr-xperl/fcgi.pl3
2 files changed, 9 insertions, 6 deletions
diff --git a/perl/cgi.pl b/perl/cgi.pl
index c5cd950..fc8e466 100755
--- a/perl/cgi.pl
+++ b/perl/cgi.pl
@@ -112,21 +112,23 @@ sub GN::cgi {
serve_template("404.tt", {}); # XXX missing code
}
-sub GN::main() {
- my $root = GIT_ROOT;
+sub GN::init() {
my %data = (
found => 0,
);
-
my %routes = (
'/' => sub { GN::index($root); },
'/~([\w.]+)' => sub { GN::user($root, @_) },
'/~([\w.]+)/([\w.]+)' => sub { GN::repository($root, @_) },
);
-
my %routes_cache = map { $_ => qr{^$_$} } keys %routes;
+ return \%data, \%routes, \%routes_cache;
+}
- GN::cgi(\%data, \%routes, \%routes_cache);
+sub GN::main() {
+ my $root = GIT_ROOT;
+ my ($data, $routes, $routes_cache) = GN::init();
+ GN::cgi($data, $routes, $routes_cache);
}
GN::main() if !caller;
diff --git a/perl/fcgi.pl b/perl/fcgi.pl
index f3701e0..823cd86 100755
--- a/perl/fcgi.pl
+++ b/perl/fcgi.pl
@@ -12,8 +12,9 @@ BEGIN { require 'cgi.pl'; }
while (1) {
try {
my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, BARE_REQUEST ? 0 : FCGI::OpenSocket(SOCKET_FILE, SOCKET_MAX_CONNECTIONS));
+ my ($data, $routes, $routes_cache) = GN::init();
while($request->Accept() >= 0) {
- GN::cgi();
+ GN::cgi($data, $routes, $routes_cache);
}
} catch ($error) {
info("Crashed: $error");