Sha256: 2d40b2e5404d45fb86884df06d9c129225c6408b02c8440f5704b80b94b6f301

Contents?: true

Size: 645 Bytes

Versions: 22

Compression:

Stored size: 645 Bytes

Contents

require 'rest-core/middleware'
require 'rest-core/util/parse_query'

class RestCore::QueryResponse
  def self.members; [:query_response]; end
  include RestCore::Middleware

  QUERY_RESPONSE_HEADER =
    {'Accept' => 'application/x-www-form-urlencoded'}.freeze

  def call env, &k
    return app.call(env, &k) if env[DRY]
    return app.call(env, &k) unless query_response(env)

    headers = QUERY_RESPONSE_HEADER.merge(env[REQUEST_HEADERS]||{})
    app.call(env.merge(REQUEST_HEADERS => headers)) do |response|
      body = ParseQuery.parse_query(response[RESPONSE_BODY])
      yield(response.merge(RESPONSE_BODY => body))
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
rest-core-3.6.0 lib/rest-core/middleware/query_response.rb
rest-core-3.5.92 lib/rest-core/middleware/query_response.rb
rest-core-3.5.91 lib/rest-core/middleware/query_response.rb
rest-core-3.5.9 lib/rest-core/middleware/query_response.rb
rest-core-3.5.8 lib/rest-core/middleware/query_response.rb
rest-core-3.5.7 lib/rest-core/middleware/query_response.rb
rest-core-3.5.6 lib/rest-core/middleware/query_response.rb
rest-core-3.5.5 lib/rest-core/middleware/query_response.rb
rest-core-3.5.4 lib/rest-core/middleware/query_response.rb
rest-core-3.5.3 lib/rest-core/middleware/query_response.rb
rest-core-3.5.2 lib/rest-core/middleware/query_response.rb
rest-core-3.5.1 lib/rest-core/middleware/query_response.rb
rest-core-3.5.0 lib/rest-core/middleware/query_response.rb
rest-core-3.4.1 lib/rest-core/middleware/query_response.rb
rest-core-3.4.0 lib/rest-core/middleware/query_response.rb
rest-core-3.3.3 lib/rest-core/middleware/query_response.rb
rest-core-3.3.2 lib/rest-core/middleware/query_response.rb
rest-core-3.3.1 lib/rest-core/middleware/query_response.rb
rest-core-3.3.0 lib/rest-core/middleware/query_response.rb
rest-core-3.2.0 lib/rest-core/middleware/query_response.rb