View | Details | Raw Unified | Return to bug 18377
Collapse All | Expand All

(-)a/app.psgi (-1 / +74 lines)
Line 0 Link Here
0
- 
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
use FindBin;
20
21
use Plack::Builder;
22
use Plack::App::CGIBin;
23
24
use Mojo::Server::PSGI;
25
26
# Pre-load libraries
27
use C4::Boolean;
28
use C4::Koha;
29
use C4::Languages;
30
use C4::Letters;
31
use C4::Members;
32
use C4::XSLT;
33
use Koha::Caches;
34
use Koha::Cache::Memory::Lite;
35
use Koha::Database;
36
use Koha::DateUtils;
37
38
use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise
39
{
40
    no warnings 'redefine';
41
    my $old_new = \&CGI::new;
42
    *CGI::new = sub {
43
        my $q = $old_new->( @_ );
44
        $CGI::PARAM_UTF8 = 1;
45
        Koha::Caches->flush_L1_caches();
46
        Koha::Cache::Memory::Lite->flush();
47
        return $q;
48
    };
49
}
50
51
my $home = $FindBin::Bin;
52
53
my $intranet = Plack::App::CGIBin->new(
54
    root => $home
55
)->to_app;
56
57
my $opac = Plack::App::CGIBin->new(
58
    root => "$home/opac"
59
)->to_app;
60
61
my $apiv1 = builder {
62
    my $server = Mojo::Server::PSGI->new;
63
    $server->load_app("$home/api/v1/app.pl");
64
    $server->to_psgi_app;
65
};
66
67
builder {
68
    enable "ReverseProxy";
69
    enable "+Koha::Middleware::SetEnv";
70
71
    mount '/opac'          => $opac;
72
    mount '/intranet'      => $intranet;
73
    mount '/api/v1/app.pl' => $apiv1;
74
};

Return to bug 18377