Method: What::Server#call

Defined in:
lib/what/server.rb

#call(env) ⇒ Object



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

def call(env)
  if Config['secret_token'] && Config['secret_token'] != env['QUERY_STRING']
    [403, {'Content-Type' => 'text/plain'}, ["403 Forbidden\n"]]
  else
    status = @monitor.status
    [
      status['health'] != 'alert' ? 200 : 503,
      {'Content-Type' => Formatter.mime},
      [Formatter.format(status)]
    ]
  end
end