Class: IsItUp::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/is_it_up/middleware.rb

Overview

If you are using Ruby on Rails, you do not need to manually insert this middleware into your middleware stack. See railtie.rb.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
# File 'lib/is_it_up/middleware.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/is_it_up/middleware.rb', line 9

def call(env)
  status, header, response =
  if env["PATH_INFO"] == "/is_it_up"
    [
      200,
      { "Content-Type" => "application/json" },
      ['{ "status": "ok", "code": 200 }']
    ]
  else
    @app.call(env)
  end
  [status, header, response]
end