class Emmy::Rack::Async
Public Class Methods
new(app, options={})
click to toggle source
# File lib/emmy/rack/async.rb, line 4 def initialize(app, options={}) @app = app @rescue_exception = options[:rescue_exception] || (->(env, ex) { [500, {}, ["Internal Server Error"]] }) end
Public Instance Methods
call(env)
click to toggle source
# File lib/emmy/rack/async.rb, line 9 def call(env) call_app = lambda do result = @app.call(env) env['async.callback'].call result end Emmy.async(&call_app) throw :async rescue => ex @rescue_exception[env, ex] end