Class: MetaRequest::Middlewares::MetaRequestHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_request/middlewares/meta_request_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ MetaRequestHandler

Returns a new instance of MetaRequestHandler.



6
7
8
# File 'lib/meta_request/middlewares/meta_request_handler.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/meta_request/middlewares/meta_request_handler.rb', line 10

def call(env)
  request_id = env['PATH_INFO'][%r{/__meta_request/(.+)\.json$}, 1]
  if request_id
    events_json(request_id)
  else
    @app.call(env)
  end
end