]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/api/ways_controller.rb
API JSON output
[rails.git] / app / controllers / api / ways_controller.rb
index 0871384a7289030397ee3eddff3d97d87ccdf297..a721f82f7ade94e92d51a76a2586cc64a9a96197 100644 (file)
@@ -11,6 +11,13 @@ module Api
     before_action :check_api_readable, :except => [:create, :update, :delete]
     around_action :api_call_handle_error, :api_call_timeout
 
+    before_action :default_format_xml
+
+    # Set format to xml unless client requires a specific format
+    def default_format_xml
+      request.format = "xml" unless params[:format]
+    end
+
     def create
       assert_method :put
 
@@ -30,6 +37,7 @@ module Api
         # Render the result
         respond_to do |format|
           format.xml
+          format.json
         end
       else
         head :gone
@@ -79,6 +87,7 @@ module Api
         # Render the result
         respond_to do |format|
           format.xml
+          format.json
         end
       else
         head :gone
@@ -99,6 +108,7 @@ module Api
       # Render the result
       respond_to do |format|
         format.xml
+        format.json
       end
     end
 
@@ -114,6 +124,7 @@ module Api
       # Render the result
       respond_to do |format|
         format.xml
+        format.json
       end
     end
   end