Class: Eipiai::HealthResource

Inherits:
Webmachine::Resource show all
Includes:
Resource
Defined in:
lib/eipiai/webmachine/resources/health.rb

Overview

ApiResource

The base resource which can be included in regular Webmachine::Resource objects. It provides sensible defaults for a full-features REST API endpoint.

Instance Method Summary collapse

Methods included from Resource

#content_types_accepted, included, #malformed_request?, #new_object, #params, #to_hash, #to_json, #unprocessable_entity?

Instance Method Details

#allowed_methodsObject



42
43
44
# File 'lib/eipiai/webmachine/resources/health.rb', line 42

def allowed_methods
  %w(GET)
end

#content_types_providedObject



46
47
48
# File 'lib/eipiai/webmachine/resources/health.rb', line 46

def content_types_provided
  [['application/json', :to_json]]
end

#objectObject



60
61
62
# File 'lib/eipiai/webmachine/resources/health.rb', line 60

def object
  HealthCheck.new
end

#representedObject



64
65
66
# File 'lib/eipiai/webmachine/resources/health.rb', line 64

def represented
  object
end

#service_available?Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
57
58
# File 'lib/eipiai/webmachine/resources/health.rb', line 50

def service_available?
  return true if healthy?

  response.headers['Content-Type'] = 'application/json'
  response.headers['Retry-After'] = '60'

  response.body = to_json
  false
end