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 error = catch(:error) do
begin begin
@app_response = @app.call(@env) @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 rescue => e
after_exception(e) after_exception(e)
raise e raise e
@ -36,7 +31,13 @@ class Grape::Middleware::Logger < Grape::Middleware::Globals
after_failure(error) after_failure(error)
throw(:error, error) throw(:error, error)
else else
after(@app_response.status) # 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 end
@app_response @app_response
end end