Class: Excon::Addressable::Middleware

Inherits:
Middleware::Base
  • Object
show all
Defined in:
lib/excon/addressable.rb

Overview

Middleware

Parses a Templated URI string and merges it with the provided variables.

Instance Method Summary collapse

Instance Method Details

#request_call(datum) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/excon/addressable.rb', line 26

def request_call(datum)
  # we need to convert a query hash (or string) to the proper format for
  # Addressable to work with. We also need to remove the `?` character
  # that Excon prepends to the final query string.
  datum[:query] = Excon::Utils.query_string(datum)[1..-1]

  url = ::Addressable::URI.new(datum)

  if (template = ::Addressable::Template.new(url)) && template.variables.any?
    uri = template.expand(datum[:expand].to_h)
    datum.merge!(uri.to_hash)
  end

  super
end