Class: Leafy::Rack::Health
- Inherits:
-
Object
- Object
- Leafy::Rack::Health
- Defined in:
- lib/leafy/rack/health.rb
Constant Summary collapse
- WRITER =
::Leafy::Json::HealthWriter.new
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, registry, path = '/health') ⇒ Health
constructor
A new instance of Health.
Constructor Details
#initialize(app, registry, path = '/health') ⇒ Health
Returns a new instance of Health.
21 22 23 24 25 |
# File 'lib/leafy/rack/health.rb', line 21 def initialize(app, registry, path = '/health') @app = app @path = path @registry = registry end |
Class Method Details
.response(health, env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/leafy/rack/health.rb', line 10 def self.response( health, env ) data = health.run_health_checks is_healthy = data.values.all? { |r| r.healthy? } [ is_healthy ? 200 : 500, { 'Content-Type' => 'application/json', 'Cache-Control' => 'must-revalidate,no-cache,no-store' }, [ WRITER.to_json( data, env[ 'QUERY_STRING' ] == 'pretty' ) ] ] end |