Bug 16751: What is sitemaper?
[koha.git] / debian / templates / plack.psgi
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 use Modern::Perl;
19
20 use lib("/usr/share/koha/lib");
21 use lib("/usr/share/koha/lib/installer");
22
23 use Plack::Builder;
24 use Plack::App::CGIBin;
25 use Plack::App::Directory;
26 use Plack::App::URLMap;
27
28 # Pre-load libraries
29 use C4::Boolean;
30 use C4::Branch;
31 use C4::Category;
32 use C4::Koha;
33 use C4::Languages;
34 use C4::Letters;
35 use C4::Members;
36 use C4::XSLT;
37 use Koha::Cache;
38 use Koha::Cache::Memory::Lite;
39 use Koha::Database;
40 use Koha::DateUtils;
41
42 use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise
43 {
44     no warnings 'redefine';
45     my $old_new = \&CGI::new;
46     *CGI::new = sub {
47         my $q = $old_new->( @_ );
48         $CGI::PARAM_UTF8 = 1;
49         Koha::Cache->flush_L1_cache();
50         Koha::Cache::Memory::Lite->flush();
51         return $q;
52     };
53 }
54
55 my $intranet = Plack::App::CGIBin->new(
56     root => '/usr/share/koha/intranet/cgi-bin'
57 )->to_app;
58
59 my $opac = Plack::App::CGIBin->new(
60     root => '/usr/share/koha/opac/cgi-bin/opac'
61 )->to_app;
62
63 # my $api  = Plack::App::CGIBin->new(
64 #     root => '/usr/share/koha/api/'
65 # )->to_app;
66
67 builder {
68
69     enable "ReverseProxy";
70     enable "Plack::Middleware::Static";
71
72     mount '/opac'     => $opac;
73     mount '/intranet' => $intranet;
74     # mount '/api'       => $api;
75 };