Class: AfterResponse::Adapters::UnicornMiddleware

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

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

#appObject

Returns the value of attribute app

Returns:

  • (Object)

    the current value of app



10
11
12
# File 'lib/after_response/adapters/unicorn_middleware.rb', line 10

def app
  @app
end

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of 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

#closeObject

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