]> git.xolatile.top Git - gorillanest.git/commitdiff
Isolate Things Pt. 2, FCGI
authorEmil Williams <emilemilemil@cock.li>
Thu, 21 Aug 2025 09:38:10 +0000 (09:38 +0000)
committerEmil Williams <emilemilemil@cock.li>
Thu, 21 Aug 2025 09:38:10 +0000 (09:38 +0000)
perl/cgi.pl
perl/fcgi.pl

index c5cd950e9a0145274c4dc49f3b85f787784099b2..fc8e4667e231a7c30f25ef4b0163a9a560513a85 100755 (executable)
@@ -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;
index f3701e0caee5f1559e4853e3601ec7efba8959ba..823cd865231fb74042021d7f645fc2d09194f173 100755 (executable)
@@ -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");