Class: Hijacker::Middleware
- Inherits:
-
Object
- Object
- Hijacker::Middleware
- Defined in:
- lib/hijacker/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
3 4 5 |
# File 'lib/hijacker/middleware.rb', line 3 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/hijacker/middleware.rb', line 7 def call(env) if env['HTTP_X_HIJACKER_DB'].present? begin Hijacker.connect(env['HTTP_X_HIJACKER_DB']) rescue Hijacker::InvalidDatabase => e return [404, {}, ""] end end @app.call(env) end |