Class: HealthRack::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/health_rack/controller.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Controller

Returns a new instance of Controller.



8
9
10
11
# File 'lib/health_rack/controller.rb', line 8

def initialize(env)
  @request = Rack::Request.new(env)
  @response = Rack::Response.new
end

Instance Method Details

#formatObject



22
23
24
25
26
27
# File 'lib/health_rack/controller.rb', line 22

def format
  @format ||= begin
    md = @request.path_info.match(/\.([a-z]+)$/i) || []
    md[1] || 'html'
  end
end

#perform(app) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/health_rack/controller.rb', line 13

def perform(app)
  renderer = renderer_class.new(app)

  renderer.render(@response)

  @response['Content-type'] = renderer.content_type
  @response.finish
end