Enable experimental proxy via configuration option 'experimental_proxy'
Change-Id: I3c5532d661327e3be50153d1360f96b524c91f29
diff --git a/Changes b/Changes
index 2a9b902..1b44d5c 100755
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.35 2019-07-17
+0.35 2019-07-18
- Added EXPERIMENTAL proxy to API route.
- Remove deprecated api configuration
(requires api_path instead now).
@@ -9,6 +9,8 @@
- Introduced documentation on Cosmas 2.
- Improved documentation on APIs.
- Introduced documentation on FCS-QL (margaretha).
+ - Enable experimental proxy via
+ configuration option 'experimental_proxy'.
0.34 2019-06-26
- Introduced guided tour (hebasta, #19).
diff --git a/kalamar.conf b/kalamar.conf
index 889a8ca..6e61b15 100644
--- a/kalamar.conf
+++ b/kalamar.conf
@@ -36,17 +36,20 @@
# Backend server path
api_path => $ENV{'KALAMAR_API'} // $api,
- # Backend API version
+ ## Backend API version
# api_version => '1.0',
- # The name of the base corpus,
- # for query examples (see kalamar.queries.dict)
- # examplecorpus => 'dereko'
+ ## The name of the base corpus,
+ ## for query examples (see kalamar.queries.dict)
+ # examplecorpus => 'dereko',
- # For further Plugins, add them
- # to this array:
- # plugins => []
- # Currently bundled: Piwik, Auth
+ ## For further Plugins, add them
+ ## to this array:
+ # plugins => [],
+ ## Currently bundled: Piwik, Auth
+
+ ## Add experimental features:
+ # experimental_proxy => 1,
},
# See Mojolicious::Plugin::TagHelpers::MailToChiffre
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index c9e9374..3f82113 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -236,8 +236,10 @@
$r->get('/contact')->mail_to_chiffre('documentation#contact');
# API proxy route
- # $r->any('/api/v#apiv' => [apiv => ['1.0']])->to('Proxy#pass');
- # $r->any('/api/v#apiv/*path' => [apiv => ['1.0']])->to('Proxy#pass');
+ if ($conf->{experimental_proxy}) {
+ $r->any('/api/v#apiv' => [apiv => ['1.0']])->to('Proxy#pass');
+ $r->any('/api/v#apiv/*path' => [apiv => ['1.0']])->to('Proxy#pass');
+ }
# Match route
# Corpus route
diff --git a/t/proxy.t b/t/proxy.t
index 84f029e..f30e049 100644
--- a/t/proxy.t
+++ b/t/proxy.t
@@ -13,7 +13,8 @@
my $t = Test::Mojo->new('Kalamar' => {
Kalamar => {
- plugins => ['Auth']
+ plugins => ['Auth'],
+ experimental_proxy => 1
}
});
@@ -32,12 +33,6 @@
# Globally set server
$t->app->ua->server->app($t->app);
-my $r = $t->app->routes;
-
-# API proxy route
-$r->any('/api/v#apiv' => [apiv => ['1.0']])->to('Proxy#pass');
-$r->any('/api/v#apiv/*path' => [apiv => ['1.0']])->to('Proxy#pass');
-
$t->get_ok('/realapi/v1.0')
->status_is(200)
->content_is('Fake server available')