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
end
def show
- way = Way.find(params[:id])
-
- response.last_modified = way.timestamp
+ @way = Way.find(params[:id])
- if way.visible
- @way = way
+ response.last_modified = @way.timestamp
+ if @way.visible
# Render the result
respond_to do |format|
format.xml
+ format.json
end
else
head :gone
end
def full
- way = Way.includes(:nodes => :node_tags).find(params[:id])
+ @way = Way.includes(:nodes => :node_tags).find(params[:id])
- if way.visible
+ if @way.visible
visible_nodes = {}
@nodes = []
- way.nodes.uniq.each do |node|
+ @way.nodes.uniq.each do |node|
if node.visible
@nodes << node
visible_nodes[node.id] = node
end
end
- @way = way
-
# Render the result
respond_to do |format|
format.xml
+ format.json
end
else
head :gone
# Render the result
respond_to do |format|
format.xml
+ format.json
end
end
# Render the result
respond_to do |format|
format.xml
+ format.json
end
end
end