Bug 15407: Koha::Patron::Categories - replace C4::Category->all
[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 use Mojo::Server::PSGI;
29
30 # Pre-load libraries
31 use C4::Boolean;
32 use C4::Branch;
33 use C4::Koha;
34 use C4::Languages;
35 use C4::Letters;
36 use C4::Members;
37 use C4::XSLT;
38 use Koha::Caches;
39 use Koha::Cache::Memory::Lite;
40 use Koha::Database;
41 use Koha::DateUtils;
42
43 use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise
44 {
45     no warnings 'redefine';
46     my $old_new = \&CGI::new;
47     *CGI::new = sub {
48         my $q = $old_new->( @_ );
49         $CGI::PARAM_UTF8 = 1;
50         Koha::Caches->flush_L1_caches();
51         Koha::Cache::Memory::Lite->flush();
52         return $q;
53     };
54 }
55
56 my $intranet = Plack::App::CGIBin->new(
57     root => '/usr/share/koha/intranet/cgi-bin'
58 )->to_app;
59
60 my $opac = Plack::App::CGIBin->new(
61     root => '/usr/share/koha/opac/cgi-bin/opac'
62 )->to_app;
63
64 my $apiv1  = builder {
65     my $server = Mojo::Server::PSGI->new;
66     $server->load_app('/usr/share/koha/api/v1/app.pl');
67     $server->to_psgi_app;
68 };
69
70 builder {
71
72     enable "ReverseProxy";
73     enable "Plack::Middleware::Static";
74
75     mount '/opac'          => $opac;
76     mount '/intranet'      => $intranet;
77     mount '/api/v1/app.pl' => $apiv1;
78 };