<p>I've been planning on a refactoring of api-related controllers for a while. For further background reading, see <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="380608633" data-permission-text="Issue title is private" data-url="https://github.com/gravitystorm/openstreetmap-website/issues/27" data-hovercard-type="issue" data-hovercard-url="/gravitystorm/openstreetmap-website/issues/27/hovercard" href="https://github.com/gravitystorm/openstreetmap-website/issues/27">gravitystorm#27</a>.</p>
<p>I want to refactor the api-related controllers to inherit from a common controller (in the same way that regular controllers normally inherit from ApplicationController). The only convention that I found has this base controller named as "ApiController", but we're already using that name. So I thought about renaming our current ApiController, to free up the name for reuse, but I couldn't figure out a good descriptive name for the actions in the current ApiController. And then I realised that's because they are mostly unrelated to each other, and so I could split them into separate controllers instead.</p>
<p>So that's what this PR does - it splits the ApiController into separate controllers for each unrelated action.</p>
<p>I've chosen to put them in an "api" namespace (aka subdirectory) since I plan to do this for the rest of the api-related controllers. It is also the end-goal for other work that I'm doing on supporting multiple API versions (see <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="397766010" data-permission-text="Issue title is private" data-url="https://github.com/gravitystorm/openstreetmap-website/issues/28" data-hovercard-type="issue" data-hovercard-url="/gravitystorm/openstreetmap-website/issues/28/hovercard" href="https://github.com/gravitystorm/openstreetmap-website/issues/28">gravitystorm#28</a>), so creating the new controllers in the subdirectory should avoid further renaming.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/openstreetmap/openstreetmap-website/pull/2160'>https://github.com/openstreetmap/openstreetmap-website/pull/2160</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Move the capabilities call out of api_controller</li>
  <li>Move the trackpoints call into its own controller (and rename to tracepoints)</li>
  <li>Rename api controller test files</li>
  <li>Move the permissions call out of api_controller</li>
  <li>Move the changes api to its own controller</li>
  <li>Move map method to its own controller</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-0">app/abilities/ability.rb</a>
    (6)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-1">app/controllers/api/capabilities_controller.rb</a>
    (21)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-2">app/controllers/api/changes_controller.rb</a>
    (57)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-3">app/controllers/api/map_controller.rb</a>
    (107)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-4">app/controllers/api/permissions_controller.rb</a>
    (27)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-5">app/controllers/api/tracepoints_controller.rb</a>
    (112)
  </li>
  <li>
    <strong>D</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-6">app/controllers/api_controller.rb</a>
    (279)
  </li>
  <li>
    <strong>R</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-7">app/views/api/capabilities/show.builder</a>
    (0)
  </li>
  <li>
    <strong>R</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-8">app/views/api/permissions/show.builder</a>
    (0)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-9">config/routes.rb</a>
    (14)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-10">test/controllers/api/capabilities_controller_test.rb</a>
    (35)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-11">test/controllers/api/changes_controller_test.rb</a>
    (106)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-12">test/controllers/api/map_controller_test.rb</a>
    (181)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-13">test/controllers/api/permissions_controller_test.rb</a>
    (51)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-14">test/controllers/api/tracepoints_controller_test.rb</a>
    (146)
  </li>
  <li>
    <strong>D</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160/files#diff-15">test/controllers/api_controller_test.rb</a>
    (435)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/2160.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/2160.patch</a></li>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/2160.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/2160.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/2160">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABWnLblsxA3soXYwtc6TbV_pgPhE4U2Oks5vR_UVgaJpZM4bXEmF">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABWnLZI8ZqksInT-I-4kI4IZ-nAtEXiVks5vR_UVgaJpZM4bXEmF.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/openstreetmap/openstreetmap-website","title":"openstreetmap/openstreetmap-website","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/openstreetmap/openstreetmap-website"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Split api_controller actions into their own controllers (#2160)"}],"action":{"name":"View Pull Request","url":"https://github.com/openstreetmap/openstreetmap-website/pull/2160"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/2160",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/2160",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>