Class: Para::IframeTransport::Middleware
- Inherits:
-
Object
- Object
- Para::IframeTransport::Middleware
- Defined in:
- lib/para/iframe_transport/middleware.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
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.
6 7 8 |
# File 'lib/para/iframe_transport/middleware.rb', line 6 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
4 5 6 |
# File 'lib/para/iframe_transport/middleware.rb', line 4 def app @app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/para/iframe_transport/middleware.rb', line 10 def call(env) status, headers, response_body = app.call(env) # Build a rails request to allow using its API to analyze the request # format and mode request = ActionDispatch::Request.new( Rails.application.env_config.merge(env) ) # If the request is an Ajax IFrame tranport one, we add a hidden field # to the response body to pass response informations that can't be # retrieved with headers to the javascript client. if matching_request?(request) add_status_to_response(request, response_body) end [status, headers, response_body] end |