2017-07-24 16:20:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:51:43 -04:00
|
|
|
require "rack/body_proxy"
|
2016-02-21 20:25:52 -05:00
|
|
|
|
|
|
|
module ActionDispatch
|
|
|
|
class Executor
|
|
|
|
def initialize(app, executor)
|
|
|
|
@app, @executor = app, executor
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
state = @executor.run!
|
|
|
|
begin
|
|
|
|
response = @app.call(env)
|
|
|
|
returned = response << ::Rack::BodyProxy.new(response.pop) { state.complete! }
|
2021-11-10 09:21:27 -05:00
|
|
|
rescue => error
|
|
|
|
@executor.error_reporter.report(error, handled: false)
|
|
|
|
raise
|
2016-02-21 20:25:52 -05:00
|
|
|
ensure
|
|
|
|
state.complete! unless returned
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|