Introduced proxy_prefix to config

Change-Id: Ia632ad467670c017e90bc0bf78924a5801aa4cf2
diff --git a/Changes b/Changes
index 7b53f14..1c38987 100755
--- a/Changes
+++ b/Changes
@@ -1,7 +1,8 @@
-0.22 2017-04-24
+0.22 2017-05-17
         - Added user authentification using Kustvakts LDAP
           connection.
         - Added X-Forwarded-For.
+        - Introduced proxy_prefix as a configuration option.
 
 0.21 2017-02-01
         - Use textSigle for API communication instead of
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index cbf4198..0b25d07 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -35,17 +35,6 @@
   # Add additional plugin path
   push(@{$self->plugins->namespaces}, __PACKAGE__ . '::Plugin');
 
-  # korap.ids-mannheim.de specific path prefixing
-  $self->hook(
-    before_dispatch => sub {
-      my $c = shift;
-      my $host = $c->req->headers->header('X-Forwarded-Host');
-      if ($host && $host eq 'korap.ids-mannheim.de') {
-        $c->req->url->base->path('/kalamar/');
-        $c->stash(prefix => '/kalamar');
-      };
-    }) if $self->mode eq 'production';
-
 
   # Set secrets for signed cookies
   if (-e (my $secret = $self->home->child('kalamar.secret'))) {
@@ -66,6 +55,20 @@
 
   $self->log->info('Mode is ' . $self->mode);
 
+  # Specific path prefixing
+  my $conf = $self->config('Kalamar');
+  if ($conf && $conf->{proxy_prefix}) {
+
+    # Set prefix in stash
+    $self->defaults(prefix => $conf->{proxy_prefix});
+
+    # Create base path
+    $self->hook(
+      before_dispatch => sub {
+        shift->req->url->base->path($conf->{proxy_prefix} . '/');
+      });
+  };
+
   # Start fixture server
   if ($self->mode eq 'test') {