Hi Roman,
On Tue, 2010-01-26 at 00:35 +0300, Roman wrote:
It looks like there is a minor issue when image, realm or flavor is
requested by id. Deltacloud API returns an error HTTP document instead
of 404 HTTP code, even if requested response format is XML. Below is a
trivial patch to address this issue.
thanks for sending the patch - error returns are indeed a problem with
the current API. Rather than produce error output separately in each
controller method, I'd prefer a more centralized approach, something
along the lines of
class ApplicationController
rescue_from NotFoundError, :with => handle_not_found
def handle_not_found(hash)
respond_to do |format|
format.html
format.json { render :nothing=>true, :status=>404 }
format.xml { render :nothing=>true, :status=>404 }
end
end
end
class FlavorsController
def show
@flavor = driver.flavor( credentials, :id => params[:id] )
raise NotFoundError unless @flavor
respond_to do |format|
format.html
format.json
format.xml {
render :xml=>convert_to_xml( :flavor, @flavor )
}
end
end
This way, individual drivers can also raise errors that we then
translate into uniform return codes etc.
David