Class: Eipiai::HealthResource

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

Overview

HealthResource

Provides basic health checking of the API. This resource can be configured to validate a working service, and return the correct availability to the client.

Instance Method Summary collapse

Methods included from Resource

#base_uri, #content_types_accepted, #create_uri, included, #malformed_request?, #new_object, #params, #post_is_create?, #query_keys, #resource_relation, #to_h, #to_hal_json, #to_json, #unprocessable_entity?

Instance Method Details

#allowed_methodsObject



48
49
50
# File 'lib/eipiai/resources/health.rb', line 48

def allowed_methods
  %w(GET)
end

#content_types_providedObject



52
53
54
# File 'lib/eipiai/resources/health.rb', line 52

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

#finish_requestObject



66
67
68
# File 'lib/eipiai/resources/health.rb', line 66

def finish_request
  response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate, private'
end

#objectObject



70
71
72
# File 'lib/eipiai/resources/health.rb', line 70

def object
  HealthCheck.new
end

#service_available?Boolean

Returns:

  • (Boolean)


56
57
58
59
60
61
62
63
64
# File 'lib/eipiai/resources/health.rb', line 56

def service_available?
  return true if healthy?

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

  response.body = to_json
  false
end

#top_level_relation?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/eipiai/resources/health.rb', line 44

def top_level_relation?
  true
end