Class: Rack::Cargo::Middleware
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Instance Method Summary collapse
- #batch_request?(path) ⇒ Boolean
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
8 9 10 |
# File 'lib/rack/cargo/middleware.rb', line 8 def initialize(app) self.app = app end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
6 7 8 |
# File 'lib/rack/cargo/middleware.rb', line 6 def app @app end |
Instance Method Details
#batch_request?(path) ⇒ Boolean
21 22 23 |
# File 'lib/rack/cargo/middleware.rb', line 21 def batch_request?(path) path == Rack::Cargo.config.batch_path end |
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/rack/cargo/middleware.rb', line 12 def call(env) if batch_request?(env[ENV_PATH]) result = BatchProcessor.process(app, env) BatchResponse.from_result(result) else @app.call(env) end end |