- case request.method
-
- when :get
- unless way.visible
- render :nothing => true, :status => 410
- return
- end
- render :text => way.to_xml.to_s
+ new_way = Way.from_xml(request.raw_post)
+
+ unless new_way && new_way.id == way.id
+ fail OSM::APIBadUserInput.new("The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})")
+ end
+
+ way.update_from(new_way, @user)
+ render :text => way.version.to_s, :content_type => "text/plain"
+ end
+
+ # This is the API call to delete a way
+ def delete
+ way = Way.find(params[:id])
+ new_way = Way.from_xml(request.raw_post)
+
+ if new_way && new_way.id == way.id
+ way.delete_with_history!(new_way, @user)
+ render :text => way.version.to_s, :content_type => "text/plain"
+ else
+ render :text => "", :status => :bad_request
+ end
+ end