<p></p>
<p dir="auto">Just as a passing comment here - in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2323536440" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/4859" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/4859/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/pull/4859">#4859</a> I managed to extract <code class="notranslate">check_api_readable</code> into <code class="notranslate">api_controller</code> (since it applies by default to most controllers).</p>
<p dir="auto">I thought about doing something similar with <code class="notranslate">check_api_writable</code>, since there's a frequent pattern of:</p>
<div class="highlight highlight-source-ruby" dir="auto"><pre class="notranslate"><span class="pl-en">before_action</span> <span class="pl-pds">:check_api_writable</span><span class="pl-kos">,</span> <span class="pl-pds">:only</span> <span class="pl-c1">=></span> <span class="pl-kos">[</span><span class="pl-pds">:create</span><span class="pl-kos">,</span> <span class="pl-pds">:update</span><span class="pl-kos">,</span> <span class="pl-pds">:destroy</span><span class="pl-kos">]</span></pre></div>
<p dir="auto">I think this could apply by default to all api controllers - for those action names, you probably want to check the database is writeable by default.</p>
<p dir="auto">What stands in the way is that many of our api controllers aren't (yet) refactored to use resourceful routing - they have idiosyncratic action names like <code class="notranslate">:subscribe</code> or <code class="notranslate">:update_all</code>. This is another place where resourceful routing refactoring, although a substantial amount of work, would prove useful in making the code easier to maintain and to build new features.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/4858#issuecomment-2138070383">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLLIK4PWVQ2PXVN6OR3ZEYQP7AVCNFSM6AAAAABIPDOOAWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZYGA3TAMZYGM">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJAUBMC537YVWDZSA3ZEYQP7A5CNFSM6AAAAABIPDOOAWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTT7OBOW6.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/issues/4858/2138070383</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/4858#issuecomment-2138070383",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/4858#issuecomment-2138070383",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>