Class: Leafy::Rack::Ping

Inherits:
Object
  • Object
show all
Defined in:
lib/leafy/rack/ping.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, path = '/ping') ⇒ Ping

Returns a new instance of Ping.



15
16
17
18
# File 'lib/leafy/rack/ping.rb', line 15

def initialize(app, path = '/ping')
  @app = app
  @path = path
end

Class Method Details

.responseObject



6
7
8
9
10
11
12
13
# File 'lib/leafy/rack/ping.rb', line 6

def self.response
  [ 
   200, 
   { 'Content-Type' => 'text/plain',
     'Cache-Control' => 'must-revalidate,no-cache,no-store' }, 
   [ 'pong' ]
  ]
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/leafy/rack/ping.rb', line 20

def call(env)
  if env['PATH_INFO'] == @path
    Ping.response
  else
    @app.call( env )
  end
end