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.

[View source]

6
7
8
9
10
# File 'lib/wellness/middleware.rb', line 6

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

Instance Method Details

#call(env) ⇒ Object

[View source]

20
21
22
23
24
25
26
27
28
29
# File 'lib/wellness/middleware.rb', line 20

def call(env)
  case env['PATH_INFO']
  when health_status_path
    @system.simple_check
  when health_details_path
    @system.detailed_check
  else
    @app.call(env)
  end
end

#health_details_pathObject

[View source]

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

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

#health_status_pathObject

[View source]

12
13
14
# File 'lib/wellness/middleware.rb', line 12

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