Class: What::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/what/server.rb

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



3
4
5
6
7
# File 'lib/what/server.rb', line 3

def initialize
  Modules.load_all
  Formatters.load_all
  Monitor.go!
end

Instance Method Details

#call(env) ⇒ Object



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

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