Class: Wellness::Middleware

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

Overview

This is to be put into the Rack environment.

Author:

  • Matthew A. Johnston

Instance Method Summary collapse

Constructor Details

#initialize(app, system, options = {}) ⇒ Middleware

Returns a new instance of Middleware.



9
10
11
12
13
# File 'lib/wellness/middleware.rb', line 9

def initialize(app, system, options={})
  @app = app
  @system = system
  @options = options
end

Instance Method Details

#call(env) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/wellness/middleware.rb', line 23

def call(env)
  case env['PATH_INFO']
  when health_status_path
    Wellness::SimpleReport.new(@system).call
  when health_details_path
    Wellness::DetailedReport.new(@system).call
  else
    @app.call(env)
  end
end

#health_details_pathObject



19
20
21
# File 'lib/wellness/middleware.rb', line 19

def health_details_path
  @options[:details_path] || '/health/details'
end

#health_status_pathObject



15
16
17
# File 'lib/wellness/middleware.rb', line 15

def health_status_path
  @options[:status_path] || '/health/status'
end