Sha256: 0774505ac109ad132d7f1b59082843cbf6dab0eda7f2961439c4336a7217e0ce

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 Bytes

Contents

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

class RestCore::Engine
  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 calculate_timeout timer
    return [] unless timer
    [timer.timeout, timer.timeout]
  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

5 entries across 5 versions & 1 rubygems

Version Path
rest-core-3.3.3 lib/rest-core/engine.rb
rest-core-3.3.2 lib/rest-core/engine.rb
rest-core-3.3.1 lib/rest-core/engine.rb
rest-core-3.3.0 lib/rest-core/engine.rb
rest-core-3.2.0 lib/rest-core/engine.rb