3 # This file is part of Koha.
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.
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.
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/>.
21 use Plack
::App
::CGIBin
;
22 use Plack
::App
::Directory
;
23 use Plack
::App
::URLMap
;
26 use Mojo
::Server
::PSGI
;
36 use Koha
::Cache
::Memory
::Lite
;
42 use CGI
qw(-utf8 ); # we will loose -utf8 under plack, otherwise
44 no warnings
'redefine';
45 my $old_new = \
&CGI
::new
;
47 my $q = $old_new->( @_ );
49 Koha
::Caches
->flush_L1_caches();
50 Koha
::Cache
::Memory
::Lite
->flush();
55 my $home = $ENV{KOHA_HOME
};
56 my $intranet = Plack
::App
::CGIBin
->new(
57 root
=> $ENV{DEV_INSTALL
}?
$home: "$home/intranet/cgi-bin"
60 my $opac = Plack
::App
::CGIBin
->new(
61 root
=> $ENV{DEV_INSTALL
}?
"$home/opac": "$home/opac/cgi-bin/opac"
65 my $server = Mojo
::Server
::PSGI
->new;
66 $server->load_app("$home/api/v1/app.pl");
73 enable
"ReverseProxy";
74 enable
"Plack::Middleware::Static";
76 # + is required so Plack doesn't try to prefix Plack::Middleware::
77 enable
"+Koha::Middleware::SetEnv";
78 enable
"+Koha::Middleware::RealIP";
80 mount
'/opac' => builder
{
81 if ( Log
::Log4perl
->get_logger('plack-opac')->has_appenders ){
82 enable
'Log4perl', category
=> 'plack-opac';
87 mount
'/intranet' => builder
{
88 if ( Log
::Log4perl
->get_logger('plack-intranet')->has_appenders ){
89 enable
'Log4perl', category
=> 'plack-intranet';
94 mount
'/api/v1/app.pl' => builder
{
95 if ( Log
::Log4perl
->get_logger('plack-api')->has_appenders ){
96 enable
'Log4perl', category
=> 'plack-api';