Class: RailsSpotlight::Middlewares::RequestHandler
- Inherits:
-
Object
- Object
- RailsSpotlight::Middlewares::RequestHandler
- Defined in:
- lib/rails_spotlight/middlewares/request_handler.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RequestHandler
constructor
A new instance of RequestHandler.
Constructor Details
#initialize(app) ⇒ RequestHandler
Returns a new instance of RequestHandler.
16 17 18 |
# File 'lib/rails_spotlight/middlewares/request_handler.rb', line 16 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/rails_spotlight/middlewares/request_handler.rb', line 20 def call(env) path_info = env['PATH_INFO'] action, content_type = path_info.match(%r{/__rails_spotlight/(.+)\.(\w+)$}).try(:captures) return handle(Rack::Request.new(env), action, content_type.try(:to_sym)) if action app.call(env) end |