[openstreetmap/openstreetmap-website] JSON output nodes, ways, relations, map (#2485)

Andy Allan notifications at github.com
Wed Jan 22 17:18:19 UTC 2020


gravitystorm commented on this pull request.



> @@ -3,6 +3,52 @@ class ApiController < ApplicationController
 
   private
 
+  ##
+  # Set default request format to xml unless a client requests a specific format,
+  # which can be done via (a) URL suffix and/or (b) HTTP Accept header, where
+  # the URL suffix always takes precedence over the Accept header.
+  def set_default_request_format

> It would be better to return 406 Not Acceptable instead of HTTP 500. Somehow the Rails framework doesn't handle this properly. but unfortunately that's outside of anything I control.

I've investigated this, and I believe it's because we wrap all api calls in our own `api_call_handle_error`. You might be able to solve this by adding

```
rescue ActionController::UnknownFormat
   head :not_acceptable
```
to the top of the list of handled exceptions at https://github.com/openstreetmap/openstreetmap-website/blob/f7f73322b3abae8648d6462914eea032a93263fd/app/controllers/application_controller.rb#L186-L204

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/2485#discussion_r369693899
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20200122/8f0d0a61/attachment-0001.htm>


More information about the rails-dev mailing list