Class: Monitors::MonitorRack

Inherits:
Object
  • Object
show all
Defined in:
lib/poolparty/monitors/monitor_rack.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/poolparty/monitors/monitor_rack.rb', line 39

def call(env)
  @env = env
  @data = env['rack.input'].read rescue nil
  @request = Rack::Request.new env
  @response = Rack::Response.new
  @instance = nil
  begin
    path_array= path_map(env['REQUEST_PATH']) || []
    verb = env['REQUEST_METHOD'].downcase
    
    new_body = map_to_method(path_array, verb)
    new_body = new_body.to_json unless (!path_array || path_array.empty? || path_array[0].nil?)
    
    @response.write new_body
    setup_callbacks
    
  # rescue Exception=>e
  #   @response.write e
  #   @response.status = 500
  end
  @response.finish # this is [response.status, response.headers, response.body]
end