+ way = Way.from_xml(request.raw_post, true)
+
+ if way
+ way.create_with_history @user
+ render :text => way.id.to_s, :content_type => "text/plain"
+ else
+ render :nothing => true, :status => :bad_request
+ end
+ end
+
+ def read
+ way = Way.find(params[:id])
+
+ response.headers['Last-Modified'] = way.timestamp.rfc822
+
+ if way.visible
+ render :text => way.to_xml.to_s, :content_type => "text/xml"
+ else
+ render :text => "", :status => :gone
+ end
+ end
+
+ def update
+ way = Way.find(params[:id])
+ new_way = Way.from_xml(request.raw_post)
+
+ if new_way and new_way.id == way.id
+ way.update_from(new_way, @user)
+ render :text => way.version.to_s, :content_type => "text/plain"
+ else
+ render :nothing => true, :status => :bad_request
+ end
+ 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 and new_way.id == way.id
+ way.delete_with_history!(new_way, @user)
+ render :text => way.version.to_s, :content_type => "text/plain"
+ else
+ render :nothing => true, :status => :bad_request
+ end
+ end