Class: ShuntCache::Middleware
- Inherits:
-
Object
- Object
- ShuntCache::Middleware
- Defined in:
- lib/shunt_cache/middleware.rb
Instance Attribute Summary collapse
-
#endpoint_matcher ⇒ Object
Returns the value of attribute endpoint_matcher.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
5 6 7 8 9 10 |
# File 'lib/shunt_cache/middleware.rb', line 5 def initialize(app, = {}) @app = app @endpoint_matcher = .fetch(:endpoint) do "/options/full_stack_status" end end |
Instance Attribute Details
#endpoint_matcher ⇒ Object
Returns the value of attribute endpoint_matcher.
3 4 5 |
# File 'lib/shunt_cache/middleware.rb', line 3 def endpoint_matcher @endpoint_matcher end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/shunt_cache/middleware.rb', line 12 def call(env) path = env.fetch('REQUEST_PATH') do env.fetch('PATH_INFO') do env.fetch('REQUEST_URI', '') end end if path.match(endpoint_matcher) && ShuntCache::Status.shunted? return ['503', {'Content-Type' => 'text/html'}, ['Maintenance']] end @app.call(env) end |