Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 74 lines (57 sloc) 2.37 KB
#!/usr/bin/env perl
use Koha;
use Plack::App::CGIBin;
use Plack::Builder;
use Koha::Plack::Util;
sub is_staff {
my $hostname = Koha::Plack::Util::GetCanonicalHostname(shift);
return 1 if $ENV{KOHA_STAFF};
return $hostname =~ /-staff|^needsandoffers\.fdlp\.gov/;
}
my $root = $ENV{KOHA_BASE} // '.';
my $main_app = Plack::App::CGIBin->new(root => $root)->to_app;
my $svc_app = Plack::App::CGIBin->new(root => "$root/svc", exec_cb => sub{1})->to_app;
use Koha::Squatting::Member 'On::PSGI';
use Koha::Squatting::Reserve 'On::PSGI';
use Koha::Squatting::Branch 'On::PSGI';
use Koha::Squatting::Z3950 'On::PSGI';
use Koha::Squatting::Catalog 'On::PSGI';
Koha::Squatting::Member->init;
Koha::Squatting::Reserve->init;
Koha::Squatting::Branch->init;
Koha::Squatting::Z3950->init;
Koha::Squatting::Catalog->init;
use Koha::Spelling;
use Koha::Autocomplete;
builder {
enable '+Koha::Plack::WarnPrefix';
enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' } 'ReverseProxy';
enable 'Deflater';
enable 'HTTPExceptions';
enable 'MethodOverride';
enable 'Expires',
content_type => ['text/css', 'application/javascript', qr!^image/!],
expires => 'access plus 1 day';
enable 'Static', path => qr{^/opac-tmpl/}, root => "$root/koha-tmpl/";
enable 'Static', path => qr{^/intranet-tmpl/}, root => "$root/koha-tmpl/";
enable 'Status', path => qr{/C4/|/Koha/|/misc/|/t/|/xt/|/etc/}, status => 404;
enable 'Rewrite', rules => sub {
Koha::Plack::Util::RedirectRootAndOpac( shift, \&is_staff )
};
enable_if { return (Plack::Request->new(shift)->cookies()->{debug} // 0) != 0 }
'Debug', panels => [
qw(Environment Response Timer Memory Session),
['DBIProfile', profile => 2],
];
enable 'Header', unset => ['Status'];
enable '+Koha::Plack::Localize';
mount '/cgi-bin/koha/' => $main_app;
mount '/members/' => sub {Koha::Squatting::Member->psgi(shift)};
mount '/branches/' => sub {Koha::Squatting::Branch->psgi(shift)};
mount '/reserves/' => sub {Koha::Squatting::Reserve->psgi(shift)};
mount '/z3950/' => sub {Koha::Squatting::Z3950->psgi(shift)};
mount '/catalog/' => sub {Koha::Squatting::Catalog->psgi(shift)};
mount '/svc/' => $svc_app;
mount '/spell/' => Koha::Spelling::psgi();
mount '/ac/' => Koha::Autocomplete::psgi();
};
Jump to Line
Something went wrong with that request. Please try again.