Răsfoiți Sursa

Use the router's dir as LIBDIR

George Baugh 5 luni în urmă
părinte
comite
a57860783c
1 a modificat fișierele cu 7 adăugiri și 0 ștergeri
  1. 7 0
      lib/TPSGI.pm

+ 7 - 0
lib/TPSGI.pm

@@ -216,9 +216,16 @@ sub new {
     # XXX TODO make these routes able to be fully qualified namespaces (::)!
     no strict 'refs';
     foreach my $route (@{$self->{routers}}) {
+
+        die "No such routing module $route" unless -f $route;
+
         # The router needs to exist and have nonzero numbers of routes.
         my ($package) = basename($route) =~ m/(\S+)\.pm$/;
         my $r = "$package\:\:routes";
+
+        my $libdir = dirname($route);
+        push(@INC, $libdir);
+
         local $@;
         $self->DEBUG("require $route");
         my $success = eval { require $route; 1; };