Sha256: 6375b3168d4b7818f23fe08ad1d9ae1f89bd1336e2dfd1a7e721365e4829eeb5

Contents?: true

Size: 634 Bytes

Versions: 3

Compression:

Stored size: 634 Bytes

Contents

class App

  def call(env)
    params = env["rack.input"].gets
    response = Rack::Response.new
    response['Content-Type'] = 'application/json'
    response.write(json_response(params))
    response.finish
  end

  private

  def json_response(params)
    hsh_params = MultiJson.load(params)
    keys = hsh_params.reduce([]) do |result, (key, value)|
      result << key
      if value.is_a?(Hash)
        result << value.keys
      end
      result
    end.flatten
    MultiJson.dump({
                       keys: keys,
                       fakeKey: true,
                       fake_key: false
                   })
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cp-sparrow-0.0.14 spec/integration/apps/rack_app/app.rb
cp-sparrow-0.0.12 spec/integration/apps/rack_app/app.rb
cp-sparrow-0.0.11 spec/integration/apps/rack_app/app.rb