Class: Weary::Adapter::Excon

Inherits:
Object
  • Object
show all
Extended by:
Weary::Adapter
Includes:
Weary::Adapter
Defined in:
lib/weary/adapters/excon.rb

Constant Summary

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Weary::Adapter

call, initialize, normalize_request_headers, normalize_response

Class Method Details

+ (Object) connect(request)



10
11
12
13
14
# File 'lib/weary/adapters/excon.rb', line 10

def connect(request)
  connection = ::Excon.new("#{request.scheme}://#{request.host_with_port}")
  response = connection.request prepare(request)
  Rack::Response.new response.body, response.status, normalize_response(response.headers)
end

+ (Object) prepare(request)



16
17
18
19
20
21
22
23
24
25
# File 'lib/weary/adapters/excon.rb', line 16

def prepare(request)
  has_query = !(request.query_string.nil? || request.query_string.empty?)
  excon_params = { :headers => normalize_request_headers(request.env),
                   :method  => request.request_method,
                   :path    => request.path,
                   :body    => request.body.read }
  excon_params[:query] if has_query
  request.body.rewind
  excon_params
end

Instance Method Details

- (Object) connect(rack_request)



30
31
32
# File 'lib/weary/adapters/excon.rb', line 30

def connect(rack_request)
  self.class.connect(rack_request)
end