612eee18b6e054fb162f138c73e4bc00d94dd1a6
[koha.git] / app.psgi
1 #!/usr/bin/perl
2
3 use CGI::Compile;
4 use CGI::Emulate::PSGI;
5 use Plack::App::URLMap;
6
7 use lib '/srv/koha';
8 my $app = Plack::App::URLMap->new;
9
10 my $from = '/srv/koha/opac';
11 my $to   = '/cgi-bin/koha';
12
13 foreach my $script ( glob "$from/*" ) {
14         my $path = $script;
15         $path =~ s{^$from}{} || die;
16
17         my $sub = eval { CGI::Compile->compile($script) };
18
19         if ( $@ ) {
20                 warn "ERROR: can't compile $script: $@";
21                 next;
22         }
23
24         my $cgi_app = CGI::Emulate::PSGI->handler($sub);
25         $app->mount( "$to/$path", $cgi_app );
26         warn "# script $script -> $to/$path";
27 }
28
29 $app;