Class: Chassis::Rack::Ping
- Inherits:
-
Object
- Object
- Chassis::Rack::Ping
- Defined in:
- lib/chassis/rack/health_check.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, &block) ⇒ Ping
constructor
A new instance of Ping.
Constructor Details
#initialize(app, &block) ⇒ Ping
Returns a new instance of Ping.
6 7 8 |
# File 'lib/chassis/rack/health_check.rb', line 6 def initialize(app, &block) @app, @block = app, block end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/chassis/rack/health_check.rb', line 10 def call(env) if '/ping' == env.fetch('PATH_INFO') if @block begin result = @block.call(::Rack::Request.new(env)) raise "health check did not return correctly" unless result rescue => boom raise HealthCheckError, boom.to_s end end [200, {'Content-Type' => 'text/plain'}, ['pong']] else @app.call env end end |