|
Lines 38-49
use Koha::DateUtils;
Link Here
|
| 38 |
use Koha::Logger; |
38 |
use Koha::Logger; |
| 39 |
|
39 |
|
| 40 |
use Log::Log4perl; |
40 |
use Log::Log4perl; |
| 41 |
use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise |
41 |
use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise |
| 42 |
{ |
42 |
{ |
| 43 |
no warnings 'redefine'; |
43 |
no warnings 'redefine'; |
| 44 |
my $old_new = \&CGI::new; |
44 |
my $old_new = \&CGI::new; |
| 45 |
*CGI::new = sub { |
45 |
*CGI::new = sub { |
| 46 |
my $q = $old_new->( @_ ); |
46 |
my $q = $old_new->(@_); |
| 47 |
$CGI::PARAM_UTF8 = 1; |
47 |
$CGI::PARAM_UTF8 = 1; |
| 48 |
Koha::Caches->flush_L1_caches(); |
48 |
Koha::Caches->flush_L1_caches(); |
| 49 |
Koha::Cache::Memory::Lite->flush(); |
49 |
Koha::Cache::Memory::Lite->flush(); |
|
Lines 51-66
use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise
Link Here
|
| 51 |
}; |
51 |
}; |
| 52 |
} |
52 |
} |
| 53 |
|
53 |
|
| 54 |
my $home = $ENV{KOHA_HOME}; |
54 |
my $home = $ENV{KOHA_HOME}; |
| 55 |
my $intranet = Plack::App::CGIBin->new( |
55 |
my $intranet = Plack::App::CGIBin->new( |
| 56 |
root => $ENV{DEV_INSTALL}? $home: "$home/intranet/cgi-bin" |
56 |
root => $ENV{DEV_INSTALL} ? $home : "$home/intranet/cgi-bin" )->to_app; |
| 57 |
)->to_app; |
|
|
| 58 |
|
57 |
|
| 59 |
my $opac = Plack::App::CGIBin->new( |
58 |
my $opac = Plack::App::CGIBin->new( |
| 60 |
root => $ENV{DEV_INSTALL}? "$home/opac": "$home/opac/cgi-bin/opac" |
59 |
root => $ENV{DEV_INSTALL} ? "$home/opac" : "$home/opac/cgi-bin/opac" ) |
| 61 |
)->to_app; |
60 |
->to_app; |
| 62 |
|
61 |
|
| 63 |
my $apiv1 = builder { |
62 |
my $apiv1 = builder { |
| 64 |
my $server = Mojo::Server::PSGI->new; |
63 |
my $server = Mojo::Server::PSGI->new; |
| 65 |
$server->load_app("$home/api/v1/app.pl"); |
64 |
$server->load_app("$home/api/v1/app.pl"); |
| 66 |
$server->to_psgi_app; |
65 |
$server->to_psgi_app; |
|
Lines 73-124
builder {
Link Here
|
| 73 |
enable "Plack::Middleware::Static"; |
72 |
enable "Plack::Middleware::Static"; |
| 74 |
|
73 |
|
| 75 |
# bz 31729, enable filesystem reload for dev plack |
74 |
# bz 31729, enable filesystem reload for dev plack |
| 76 |
enable "Refresh", cooldown => 3 if ($ENV{DEV_INSTALL} ; |
75 |
enable "Refresh", cooldown => 3 |
|
|
76 |
if ( $ENV{DEV_INSTALL} ); |
| 77 |
|
77 |
|
| 78 |
# + is required so Plack doesn't try to prefix Plack::Middleware:: |
78 |
# + is required so Plack doesn't try to prefix Plack::Middleware:: |
| 79 |
enable "+Koha::Middleware::SetEnv"; |
79 |
enable "+Koha::Middleware::SetEnv"; |
| 80 |
enable "+Koha::Middleware::RealIP"; |
80 |
enable "+Koha::Middleware::RealIP"; |
| 81 |
|
81 |
|
| 82 |
mount '/opac' => builder { |
82 |
mount '/opac' => builder { |
|
|
83 |
|
| 83 |
#NOTE: it is important that these are relative links |
84 |
#NOTE: it is important that these are relative links |
| 84 |
enable 'ErrorDocument', |
85 |
enable 'ErrorDocument', |
| 85 |
400 => 'errors/400.pl', |
86 |
400 => 'errors/400.pl', |
| 86 |
401 => 'errors/401.pl', |
87 |
401 => 'errors/401.pl', |
| 87 |
402 => 'errors/402.pl', |
88 |
402 => 'errors/402.pl', |
| 88 |
403 => 'errors/403.pl', |
89 |
403 => 'errors/403.pl', |
| 89 |
404 => 'errors/404.pl', |
90 |
404 => 'errors/404.pl', |
| 90 |
500 => 'errors/500.pl', |
91 |
500 => 'errors/500.pl', |
| 91 |
subrequest => 1; |
92 |
subrequest => 1; |
|
|
93 |
|
| 92 |
#NOTE: Without this middleware to catch fatal errors, ErrorDocument won't be able to render a 500 document |
94 |
#NOTE: Without this middleware to catch fatal errors, ErrorDocument won't be able to render a 500 document |
| 93 |
#NOTE: This middleware must be closer to the PSGI app than ErrorDocument |
95 |
#NOTE: This middleware must be closer to the PSGI app than ErrorDocument |
| 94 |
enable "HTTPExceptions"; |
96 |
enable "HTTPExceptions"; |
| 95 |
if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ){ |
97 |
if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ) { |
| 96 |
enable 'Log4perl', category => 'plack-opac'; |
98 |
enable 'Log4perl', category => 'plack-opac'; |
| 97 |
enable 'LogWarn'; |
99 |
enable 'LogWarn'; |
| 98 |
} |
100 |
} |
| 99 |
$opac; |
101 |
$opac; |
| 100 |
}; |
102 |
}; |
| 101 |
mount '/intranet' => builder { |
103 |
mount '/intranet' => builder { |
|
|
104 |
|
| 102 |
#NOTE: it is important that these are relative links |
105 |
#NOTE: it is important that these are relative links |
| 103 |
enable 'ErrorDocument', |
106 |
enable 'ErrorDocument', |
| 104 |
400 => 'errors/400.pl', |
107 |
400 => 'errors/400.pl', |
| 105 |
401 => 'errors/401.pl', |
108 |
401 => 'errors/401.pl', |
| 106 |
402 => 'errors/402.pl', |
109 |
402 => 'errors/402.pl', |
| 107 |
403 => 'errors/403.pl', |
110 |
403 => 'errors/403.pl', |
| 108 |
404 => 'errors/404.pl', |
111 |
404 => 'errors/404.pl', |
| 109 |
500 => 'errors/500.pl', |
112 |
500 => 'errors/500.pl', |
| 110 |
subrequest => 1; |
113 |
subrequest => 1; |
|
|
114 |
|
| 111 |
#NOTE: Without this middleware to catch fatal errors, ErrorDocument won't be able to render a 500 document |
115 |
#NOTE: Without this middleware to catch fatal errors, ErrorDocument won't be able to render a 500 document |
| 112 |
#NOTE: This middleware must be closer to the PSGI app than ErrorDocument |
116 |
#NOTE: This middleware must be closer to the PSGI app than ErrorDocument |
| 113 |
enable "HTTPExceptions"; |
117 |
enable "HTTPExceptions"; |
| 114 |
if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ){ |
118 |
if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ) { |
| 115 |
enable 'Log4perl', category => 'plack-intranet'; |
119 |
enable 'Log4perl', category => 'plack-intranet'; |
| 116 |
enable 'LogWarn'; |
120 |
enable 'LogWarn'; |
| 117 |
} |
121 |
} |
| 118 |
$intranet; |
122 |
$intranet; |
| 119 |
}; |
123 |
}; |
| 120 |
mount '/api/v1/app.pl' => builder { |
124 |
mount '/api/v1/app.pl' => builder { |
| 121 |
if ( Log::Log4perl->get_logger('plack-api')->has_appenders ){ |
125 |
if ( Log::Log4perl->get_logger('plack-api')->has_appenders ) { |
| 122 |
enable 'Log4perl', category => 'plack-api'; |
126 |
enable 'Log4perl', category => 'plack-api'; |
| 123 |
enable 'LogWarn'; |
127 |
enable 'LogWarn'; |
| 124 |
} |
128 |
} |
| 125 |
- |
|
|