Class: RackRabbit::Handler
- Inherits:
-
Object
- Object
- RackRabbit::Handler
- Defined in:
- lib/rack-rabbit/handler.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
————————————————————————–.
-
#config ⇒ Object
readonly
————————————————————————–.
-
#logger ⇒ Object
readonly
————————————————————————–.
Instance Method Summary collapse
-
#handle(message) ⇒ Object
————————————————————————–.
-
#initialize(app, config) ⇒ Handler
constructor
————————————————————————–.
Constructor Details
#initialize(app, config) ⇒ Handler
12 13 14 15 16 |
# File 'lib/rack-rabbit/handler.rb', line 12 def initialize(app, config) @app = app @config = config @logger = config.logger end |
Instance Attribute Details
#app ⇒ Object (readonly)
8 9 10 |
# File 'lib/rack-rabbit/handler.rb', line 8 def app @app end |
#config ⇒ Object (readonly)
8 9 10 |
# File 'lib/rack-rabbit/handler.rb', line 8 def config @config end |
#logger ⇒ Object (readonly)
8 9 10 |
# File 'lib/rack-rabbit/handler.rb', line 8 def logger @logger end |
Instance Method Details
#handle(message) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rack-rabbit/handler.rb', line 20 def handle() env = .get_rack_env(config.rack_env) status, headers, body_chunks = app.call(env) body = [] body_chunks.each{|c| body << c } body_chunks.close if body_chunks.respond_to?(:close) Response.new(status, headers, body.join) rescue Exception => e # don't let exceptions bubble out of worker process logger.error e logger.error e.backtrace.join("\n") Response.new(500, {}, "Internal Server Error") end |