aserafin / grape_logging

Request logging for Grape!
MIT License
147 stars 76 forks source link

Not working with grape 0.12 #6

Closed dmitry closed 9 years ago

dmitry commented 9 years ago

After upgrading I see:

NoMethodError (undefined method `downcase' for 2:Fixnum)

An issue that response method tries to get an array values from @app_response, but it can't because @app_response stores Rack::Response instead of an array.

Don't know yet how to fix that issue, any suggestion can be helpful and transformed into a PR.

jgeggatt commented 9 years ago

@dmitry I don't totally understand what's going on, but it seems that Grape Middleware is trying to convert the @app_response object into a Rack::Response, but as you mentioned, @app_response is already a Rack::Response, so the error gets raised. To me, this seems like a problem on the Grape side, because I can't find anything that grape_logging is doing to futz with the @app_response value (that gets set from @app.call). So to get around it:

module Grape
  module Middleware
    class Base
      def response
        return @app_response if @app_response.is_a?(Rack::Response)
        super
      end
    end
  end
end
dmitry commented 9 years ago

@jgeggatt thank you for helping me. Just pushed fix to the grape.