Sha256: 1504e689f2b70f98449823d971d101e1cfbbbe615819c5beecfafeb29639c548

Contents?: true

Size: 717 Bytes

Versions: 18

Compression:

Stored size: 717 Bytes

Contents

require 'rest-core/middleware'

require 'restclient'

class RestCore::RestClient
  include RestCore::Middleware
  def call env
    respond(env,
            ::RestClient::Request.execute(:method  => env[REQUEST_METHOD ],
                                          :url     => request_uri(env)    ,
                                          :payload => env[REQUEST_PAYLOAD],
                                          :headers => env[REQUEST_HEADERS]))

  rescue ::RestClient::Exception => e
    respond(env, e.response)
  end

  def respond env, response
    env.merge(RESPONSE_BODY    => response.body,
              RESPONSE_STATUS  => response.code,
              RESPONSE_HEADERS => response.raw_headers)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rest-core-0.8.2 lib/rest-core/app/rest-client.rb
rest-core-0.8.1 lib/rest-core/app/rest-client.rb
rest-core-0.8.0 lib/rest-core/app/rest-client.rb
rest-core-0.7.2 lib/rest-core/app/rest-client.rb
rest-core-0.7.0 lib/rest-core/app/rest-client.rb
rest-core-0.4.0 lib/rest-core/app/rest-client.rb
rest-core-0.4.0.pre.2 lib/rest-core/app/rest-client.rb
rest-core-0.4.0.pre.1 lib/rest-core/app/rest-client.rb
rest-core-0.4.0.pre.0 lib/rest-core/app/rest-client.rb
rest-core-0.3.0 lib/rest-core/app/rest-client.rb
rest-core-0.3.0.pre.2 lib/rest-core/app/rest-client.rb
rest-core-0.3.0.pre.1 lib/rest-core/app/rest-client.rb
rest-core-0.3.0.pre.0 lib/rest-core/app/rest-client.rb
rest-core-0.2.3 lib/rest-core/app/rest-client.rb
rest-core-0.2.2 lib/rest-core/app/rest-client.rb
rest-core-0.2.1 lib/rest-core/app/rest-client.rb
rest-core-0.2.0 lib/rest-core/app/rest-client.rb
rest-core-0.0.1 lib/rest-core/app/rest-client.rb