Class: AfterResponse::Adapters::UnicornMiddleware
- Inherits:
-
Struct
- Object
- Struct
- AfterResponse::Adapters::UnicornMiddleware
- Defined in:
- lib/after_response/adapters/unicorn_middleware.rb
Overview
Example (in config.ru):
require 'after_response/adapters/unicorn'
use AfterResponse::Adapters::UnicornMiddleware
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#body ⇒ Object
Returns the value of attribute body.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#close ⇒ Object
In Unicorn, this is called after the socket is closed.
- #each(&block) ⇒ Object
-
#initialize(app) ⇒ UnicornMiddleware
constructor
A new instance of UnicornMiddleware.
Constructor Details
#initialize(app) ⇒ UnicornMiddleware
Returns a new instance of UnicornMiddleware.
12 13 14 |
# File 'lib/after_response/adapters/unicorn_middleware.rb', line 12 def initialize(app) super(app) end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app
10 11 12 |
# File 'lib/after_response/adapters/unicorn_middleware.rb', line 10 def app @app end |
#body ⇒ Object
Returns the value of attribute body
10 11 12 |
# File 'lib/after_response/adapters/unicorn_middleware.rb', line 10 def body @body end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 |
# File 'lib/after_response/adapters/unicorn_middleware.rb', line 16 def call(env) status, headers, self.body = app.call(env) [ status, headers, self ] end |
#close ⇒ Object
In Unicorn, this is called after the socket is closed. (Not true for at least passenger3)
26 27 28 29 |
# File 'lib/after_response/adapters/unicorn_middleware.rb', line 26 def close body.close if body.respond_to?(:close) AfterResponse::Callbacks.perform_after_response_callbacks! end |
#each(&block) ⇒ Object
21 22 23 |
# File 'lib/after_response/adapters/unicorn_middleware.rb', line 21 def each(&block) body.each(&block) end |