Sha256: 991a35cf924ff1d91601c91ec6f8e3a45644ab21376b71631674613171808d86

Contents?: true

Size: 824 Bytes

Versions: 2

Compression:

Stored size: 824 Bytes

Contents

require 'rest-core/promise'
require 'rest-core/middleware'

class RestCore::Engine
  def self.members; [:config_engine]; end
  include RestCore::Middleware

  def call env, &k
    req     = env.merge(REQUEST_URI => request_uri(env))
    promise = Promise.new(req, k, req[ASYNC])
    promise.defer{ request(promise, req) }
    promise.future_response
  end

  private
  def payload_and_headers env
    Payload.generate_with_headers(env[REQUEST_PAYLOAD], env[REQUEST_HEADERS])
  end

  def normalize_headers headers
    headers.inject({}){ |r, (k, v)|
      r[k.to_s.upcase.tr('-', '_')] = if v.kind_of?(Array) && v.size == 1
                                        v.first
                                      else
                                        v
                                      end
      r
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rest-core-3.5.6 lib/rest-core/engine.rb
rest-core-3.5.5 lib/rest-core/engine.rb