Remove default endpoint from config file
Change-Id: I1bc5ac2b0972d149e217898d28111bf5c7a7e89d
diff --git a/Changes b/Changes
index 947d6d6..bfbfe42 100755
--- a/Changes
+++ b/Changes
@@ -1,4 +1,7 @@
-0.41 2021-01-14
+0.41 2021-01-15
+ - Remove default api endpoint from config to
+ enable changes in the 'Kalamar' config environment
+ while keeping the api_path.
- Introduce CORS headers to the proxy.
- Introduce Content Security Policy.
diff --git a/kalamar.conf b/kalamar.conf
index 63dad82..bb2808f 100644
--- a/kalamar.conf
+++ b/kalamar.conf
@@ -29,12 +29,10 @@
# - Piwik
# See Mojolicious::Plugin::Piwik
-# The default Kustvakt api endpoint
-my $api = 'https://korap.ids-mannheim.de/api/';
{
Kalamar => {
- # Backend server path
- api_path => $ENV{'KALAMAR_API'} // $api,
+ ## Backend server path
+ # api_path => 'https://korap.example.org/api/',
## Backend API version
# api_version => '1.0',
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index f5a111d..9ec798e 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -74,10 +74,6 @@
);
};
- unless ($conf->{api_path} || $ENV{KALAMAR_API}) {
- $self->log->warn('Kalamar-api_path not defined in configuration');
- };
-
$self->sessions->cookie_name('kalamar');
# Require HTTPS
@@ -139,8 +135,8 @@
}
);
- # API is not yet set - define
- $conf->{api_path} //= $ENV{KALAMAR_API};
+ # API is not yet set - define the default Kustvakt api endpoint
+ $conf->{api_path} //= $ENV{KALAMAR_API} || 'https://korap.ids-mannheim.de/api/';
$conf->{api_version} //= $API_VERSION;
# Add development path
@@ -343,7 +339,7 @@
=head2 COPYRIGHT AND LICENSE
-Copyright (C) 2015-2020, L<IDS Mannheim|http://www.ids-mannheim.de/>
+Copyright (C) 2015-2021, L<IDS Mannheim|http://www.ids-mannheim.de/>
Author: L<Nils Diewald|http://nils-diewald.de/>
Kalamar is developed as part of the L<KorAP|http://korap.ids-mannheim.de/>
diff --git a/t/api.t b/t/api.t
new file mode 100644
index 0000000..5570d0d
--- /dev/null
+++ b/t/api.t
@@ -0,0 +1,32 @@
+use Mojo::Base -strict;
+use Test::More;
+use Test::Mojo;
+
+our %ENV;
+
+my $app = Test::Mojo->new('Kalamar')->app;
+is($app->korap->api, 'https://korap.ids-mannheim.de/api/v1.0/');
+
+
+$ENV{KALAMAR_API} = 'https://example.com/';
+$app = Test::Mojo->new('Kalamar')->app;
+is($app->korap->api, 'https://example.com/v1.0/');
+
+$app = Test::Mojo->new('Kalamar' => {
+ Kalamar => {
+ api_path => 'https://example.org/'
+ }
+})->app;
+is($app->korap->api, 'https://example.org/v1.0/');
+
+$ENV{KALAMAR_API} = undef;
+$app = Test::Mojo->new('Kalamar' => {
+ Kalamar => {
+ api_version => '1.1'
+ }
+})->app;
+is($app->korap->api, 'https://korap.ids-mannheim.de/api/v1.1/');
+
+
+done_testing;
+__END__