Class: Visor::Image::HeadImage
- Inherits:
-
Goliath::API
- Object
- Goliath::API
- Visor::Image::HeadImage
- Includes:
- Common::Exception, Common::Util
- Defined in:
- lib/image/routes/head_image.rb
Overview
Head metadata about the image with the given id.
Instance Method Summary collapse
-
#exit_error(code, message) ⇒ Array
Produce an HTTP response with an error code and message.
-
#on_headers(env, headers) ⇒ Object
Pre-process headers as they arrive and load them into a environment variable.
-
#response(env) ⇒ Object
Query database to retrieve the wanted image meta and return it as HTTP headers.
Instance Method Details
#exit_error(code, message) ⇒ Array
Produce an HTTP response with an error code and message.
46 47 48 49 |
# File 'lib/image/routes/head_image.rb', line 46 def exit_error(code, ) logger.error [code, {'x-error-code' => code.to_s, 'x-error-message' => }, nil] end |
#on_headers(env, headers) ⇒ Object
Pre-process headers as they arrive and load them into a environment variable.
17 18 19 20 |
# File 'lib/image/routes/head_image.rb', line 17 def on_headers(env, headers) logger.debug "Received headers: #{headers.inspect}" env['headers'] = headers end |
#response(env) ⇒ Object
Query database to retrieve the wanted image meta and return it as HTTP headers.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/image/routes/head_image.rb', line 26 def response(env) (env, vas) = vms.get_image(params[:id]) header = () [200, header, nil] rescue Forbidden => e exit_error(403, e.) rescue NotFound => e exit_error(404, e.) rescue InternalError => e exit_error(503, e.) end |