openstreetmap / openstreetmap-website

The Rails application that powers OpenStreetMap
https://www.openstreetmap.org/
GNU General Public License v2.0
2.08k stars 907 forks source link

Refactor api_call_* filters #4861

Open gravitystorm opened 1 month ago

gravitystorm commented 1 month ago

Most controllers have the same set of around_action filters, e.g.

around_action :api_call_handle_error, :api_call_timeout

However, some don't:

I would like to refactor the controllers, similar to #4859 so that these handlers are applied by default, and exceptions are used (e.g. skip_around_action only where necessary.

gravitystorm commented 1 month ago

I tried this today, and one complication was related to the order of the adding the api_call_handle_error and authorizing the action - moving the handler into api_controller meant that api_call_handle_error grabbed the CanCanCan exception itself.

AntonKhorev commented 1 month ago

Some controllers (traces?) have different error handlers for different actions. One action may support xml error responses, other may not.