Koha/debian/templates/plack.psgi
Jesse Weaver 1e6df24d6c Bug 16520: Allow per-VirtualHost environment variables with Plack
This allows OVERRIDE_SYSPREF_* and others to work properly.

Test plan:

  1) Add the following line to your plack.psgi (near the bottom, just
     above "mount ..."):
       enable "+Koha::Middleware::Plack";
  2) Load the OPAC advanced search page (under Plack). The title should
    read "Koha online catalog" (or whatever your LibraryName syspref
    contains).
  3) Add the following to your Apache configuration:
       RequestHeader add X-Koha-SetEnv "OVERRIDE_SYSPREF_LibraryName Potato\, Potato"
  4) Restart Apache.
  5) Refresh. The title should now read "Potato, Potato online catalog".

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
2016-10-11 12:49:42 +00:00

80 lines
2.1 KiB
Perl
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/perl
# This file is part of Koha.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use Modern::Perl;
use lib("/usr/share/koha/lib");
use lib("/usr/share/koha/lib/installer");
use Plack::Builder;
use Plack::App::CGIBin;
use Plack::App::Directory;
use Plack::App::URLMap;
use Plack::Request;
use Mojo::Server::PSGI;
# Pre-load libraries
use C4::Boolean;
use C4::Koha;
use C4::Languages;
use C4::Letters;
use C4::Members;
use C4::XSLT;
use Koha::Caches;
use Koha::Cache::Memory::Lite;
use Koha::Database;
use Koha::DateUtils;
use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise
{
no warnings 'redefine';
my $old_new = \&CGI::new;
*CGI::new = sub {
my $q = $old_new->( @_ );
$CGI::PARAM_UTF8 = 1;
Koha::Caches->flush_L1_caches();
Koha::Cache::Memory::Lite->flush();
return $q;
};
}
my $intranet = Plack::App::CGIBin->new(
root => '/usr/share/koha/intranet/cgi-bin'
)->to_app;
my $opac = Plack::App::CGIBin->new(
root => '/usr/share/koha/opac/cgi-bin/opac'
)->to_app;
my $apiv1 = builder {
my $server = Mojo::Server::PSGI->new;
$server->load_app('/usr/share/koha/api/v1/app.pl');
$server->to_psgi_app;
};
builder {
enable "ReverseProxy";
enable "Plack::Middleware::Static";
# + is required so Plack doesn't try to prefix Plack::Middleware::
enable "+Koha::Middleware::SetEnv";
mount '/opac' => $opac;
mount '/intranet' => $intranet;
mount '/api/v1/app.pl' => $apiv1;
};