Document the API URI

Change-Id: I6d8d11723e38b5587fdc820780a2e686d4025625
diff --git a/Changes b/Changes
index 814d88e..3e6d12f 100755
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
-0.38 2020-02-03
+0.38 2020-02-04
         - Support X-Forwarded-Host name for proxy.
+        - Document API URI.
 
 0.37 2020-01-16
         - Removed deprecated 'kalamar_test_port' helper.
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 3a60f5c..2ef30df 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -282,7 +282,7 @@
 
   # API proxy route
   if ($conf->{experimental_proxy}) {
-    $r->any('/api/v#apiv' => [apiv => ['1.0']])->to('Proxy#pass');
+    $r->any('/api/v#apiv' => [apiv => ['1.0']])->name('proxy')->to('Proxy#pass');
     $r->any('/api/v#apiv/*path' => [apiv => ['1.0']])->to('Proxy#pass');
   }
 
diff --git a/t/doc.t b/t/doc.t
index ca58755..4fb7464 100644
--- a/t/doc.t
+++ b/t/doc.t
@@ -4,7 +4,12 @@
 
 # Test the documentation
 
-my $t = Test::Mojo->new('Kalamar');
+my $t = Test::Mojo->new('Kalamar' => {
+  Kalamar => {
+    experimental_proxy => 1,
+    proxy_prefix => '/test'
+  }
+});
 
 # Embedding
 $t->get_ok('/doc/ql/poliqarp-plus')
@@ -93,4 +98,10 @@
   ->text_is('#segments pre.query.tutorial:nth-of-type(1) code', 'Beispiel')
   ->text_is('#segments pre.query.tutorial:nth-of-type(1) span', '*');
 
+# Check API endpoint
+$t->get_ok('/doc/api' => { 'X-Forwarded-Host' => 'korap.ids-mannheim.de' })
+  ->status_is(200)
+  ->text_is('#api-service-uri', 'https://korap.ids-mannheim.de/test/api/v1.0/');
+
+
 done_testing();
diff --git a/templates/doc/api.html.ep b/templates/doc/api.html.ep
index 4aaacf2..a7f1a30 100644
--- a/templates/doc/api.html.ep
+++ b/templates/doc/api.html.ep
@@ -7,3 +7,9 @@
   All API endpoints either use KoralQuery or are (more or lest) REST-ful web APIs.</p>
 
 <p>All publicly available API endpoints including their requests and responses are described in the <%= ext_link_to 'GitHub Wiki', "https://github.com/KorAP/Kustvakt/wiki" %> of <%= embedded_link_to 'doc', 'Kustvakt', 'korap', 'kustvakt' %>.</p>
+
+% if (app->config('Kalamar')->{experimental_proxy}) {
+%   my $api_url = $c->url_for('proxy' => (apiv => $Kalamar::API_VERSION))->to_abs->scheme('https');
+%   $api_url->path->trailing_slash(1);
+<p>The root service can be found at <code id="api-service-uri"><%=  $api_url %></code>.</p>
+% }