<div id='api-doc'>
<h1>debci API documentation</h1>

<% host = request.scheme + '://' + request.host %>
<% if ! [['http', 80], ['https', 443]].include?([request.scheme, request.port]) %>
  <% host += ":%d" % request.port %>
<% end %>

<p>
All requests to the API must provide a valid API key in the
<code>Auth-Key</code> HTTP header. The only exception are the endpoints that
manipulate the API keys themselves, in which case the requests must be
authenticated using another method (HTTP basic authentication, client
certificates, etc).
</p>
<p>
Example:
</p>
<pre>$ KEY='00000000-0000-0000-0000-000000000000'
$ curl --header "Auth-Key: $KEY" <%= host %>/api/v1/auth</pre>
<p>
To get an API key, you first need to be logged-in the
<a href="user">self-service interface</a>. You should then see a "Get API Key"
button that will redirect you to the right page.
</p>

<% @doc.each do |entry| %>
  <h2 id="<%= entry[:anchor] %>">
    <%= entry[:method] %>
    <%= request.script_name %><%= entry[:path] %>
    <a href="#<%= entry[:anchor] %>">&para;</a>
  </h2>
  <%== entry[:text].gsub('https://host', host) %>
<% end %>
</div>
