[openstreetmap/openstreetmap-website] Refactor usage of check_api_readable/writable (Issue #4858)

Andy Allan notifications at github.com
Wed May 29 18:59:11 UTC 2024


Just as a passing comment here - in #4859 I managed to extract `check_api_readable` into `api_controller` (since it applies by default to most controllers).

I thought about doing something similar with `check_api_writable`, since there's a frequent pattern of:

```ruby
before_action :check_api_writable, :only => [:create, :update, :destroy]
```
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.

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 `:subscribe` or `:update_all`. 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.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/4858#issuecomment-2138070383
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/issues/4858/2138070383 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240529/b0eddc6d/attachment-0001.htm>


More information about the rails-dev mailing list