Class: HttpHealthCheck::RackApp
- Inherits:
-
Object
- Object
- HttpHealthCheck::RackApp
- Defined in:
- lib/http_health_check/rack_app.rb
Constant Summary collapse
- HEADERS =
{ 'Content-Type' => 'application/json' }.freeze
- DEFAULT_FALLBACK_APP =
->(_env) { [404, HEADERS, ['{"error": "not_found"}']] }.freeze
- LIVENESS_CHECK_APP =
->(_env) { [200, HEADERS, ["{}\n"]] }
Instance Attribute Summary collapse
-
#fallback_app ⇒ Object
readonly
Returns the value of attribute fallback_app.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(routes, fallback_app: DEFAULT_FALLBACK_APP, logger: nil) ⇒ RackApp
constructor
A new instance of RackApp.
Constructor Details
#initialize(routes, fallback_app: DEFAULT_FALLBACK_APP, logger: nil) ⇒ RackApp
Returns a new instance of RackApp.
20 21 22 23 24 25 26 |
# File 'lib/http_health_check/rack_app.rb', line 20 def initialize(routes, fallback_app: DEFAULT_FALLBACK_APP, logger: nil) @logger = logger || Logger.new(IO::NULL, level: Logger::Severity::UNKNOWN) @fallback_app = ensure_callable!(fallback_app) @routes = routes.each_with_object('/liveness' => LIVENESS_CHECK_APP) do |(path, handler), acc| acc[path.to_s] = ensure_callable!(handler) end end |
Instance Attribute Details
#fallback_app ⇒ Object (readonly)
Returns the value of attribute fallback_app.
27 28 29 |
# File 'lib/http_health_check/rack_app.rb', line 27 def fallback_app @fallback_app end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
27 28 29 |
# File 'lib/http_health_check/rack_app.rb', line 27 def logger @logger end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
27 28 29 |
# File 'lib/http_health_check/rack_app.rb', line 27 def routes @routes end |
Class Method Details
.configure {|config| ... } ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/http_health_check/rack_app.rb', line 12 def self.configure config = Config::Dsl.new yield config fallback_app = config.configured_fallback_app || DEFAULT_FALLBACK_APP new(config.routes, fallback_app: fallback_app, logger: config.configured_logger) end |