ruby-grape/grape-on-rack

View on GitHub
api/wrap_response_decorator.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Acme
  class WrapResponseDecorator
    def initialize(app)
      @app = app
    end

    def call(env)
      status, headers, body_proxy = @app.call(env)
      bodies = body_proxy.map do |body|
        { body: JSON.parse(body), status: status }.to_json
      end
      [200, headers, bodies]
    end
  end
end