Class: EzClient

Inherits:
Object
  • Object
show all
Defined in:
lib/ezclient.rb,
lib/ezclient/version.rb

Defined Under Namespace

Classes: Request, Response

Constant Summary collapse

VERSION =
"0.4.0"

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ EzClient

Returns a new instance of EzClient.



9
10
11
12
# File 'lib/ezclient.rb', line 9

def initialize(options = {})
  self.options = options
  self.clients = {}
end

Instance Method Details

#request(verb, url, **options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ezclient.rb', line 14

def request(verb, url, **options)
  keep_alive_timeout = options.delete(:keep_alive)

  if keep_alive_timeout
    client = persistent_client_for(url, timeout: keep_alive_timeout)
  else
    client = HTTP::Client.new
  end

  Request.new(verb, url, client: client, **default_options, **options)
end