Return @app_response as returned by @app.call

This commit is contained in:
tinexw 2015-11-17 01:13:40 +01:00
parent 7ba0dba6fa
commit c0327a4b8d
1 changed files with 7 additions and 6 deletions

View File

@ -21,11 +21,6 @@ class Grape::Middleware::Logger < Grape::Middleware::Globals
error = catch(:error) do
begin
@app_response = @app.call(@env)
# Usually a rack response object is returned: https://github.com/ruby-grape/grape/blob/master/UPGRADING.md#changes-in-middleware
# However, rack/auth/abstract/handler.rb still returns an array instead of a rack response object.
if @app_response.is_a?(Array)
@app_response = Rack::Response.new(@app_response[2], @app_response[0], @app_response[1])
end
rescue => e
after_exception(e)
raise e
@ -35,9 +30,15 @@ class Grape::Middleware::Logger < Grape::Middleware::Globals
if error
after_failure(error)
throw(:error, error)
else
# Usually a rack response object is returned: https://github.com/ruby-grape/grape/blob/master/UPGRADING.md#changes-in-middleware
# However, rack/auth/abstract/handler.rb still returns an array instead of a rack response object.
if @app_response.is_a?(Array)
after(@app_response[0])
else
after(@app_response.status)
end
end
@app_response
end