Class: Goliath::Rack::Heartbeat
- Inherits:
-
Object
- Object
- Goliath::Rack::Heartbeat
- Defined in:
- lib/goliath/rack/heartbeat.rb
Overview
A heartbeat mechanism for the server. This will add a /status endpoint that returns status 200 and content OK when executed.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ Heartbeat
constructor
A new instance of Heartbeat.
Constructor Details
#initialize(app, opts = {}) ⇒ Heartbeat
Returns a new instance of Heartbeat.
10 11 12 13 14 15 |
# File 'lib/goliath/rack/heartbeat.rb', line 10 def initialize(app, opts = {}) @app = app @opts = opts @opts[:path] ||= '/status' @opts[:response] ||= [200, {}, 'OK'] end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/goliath/rack/heartbeat.rb', line 17 def call(env) if env['PATH_INFO'] == @opts[:path] env[Goliath::Constants::RACK_LOGGER] = Log4r::Logger.root unless @opts[:log] @opts[:response] else @app.call(env) end end |