Class: SimpleHealth::Middleware
- Inherits:
-
Object
- Object
- SimpleHealth::Middleware
- Defined in:
- lib/simple_health.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
7 8 9 |
# File 'lib/simple_health.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/simple_health.rb', line 11 def call(env) if env['PATH_INFO'] == '/health' report = Checker.status_report status = report[:services][:database] == "connected" ? 200 : 503 # Questo array di 3 elementi รจ la "risposta" [ status, # 1. Lo stato (200 o 503) { 'content-type' => 'application/json' }, # 2. Gli header (il tipo di file) [report.to_json] # 3. Il corpo (il contenuto JSON vero e proprio) ] else @app.call(env) end end |