lib/ezclient.rb in ezclient-0.4.0 vs lib/ezclient.rb in ezclient-0.5.0

- old
+ new

@@ -10,19 +10,24 @@ self.options = options self.clients = {} end def request(verb, url, **options) + options = { **default_options, **options } + keep_alive_timeout = options.delete(:keep_alive) + api_auth = options.delete(:api_auth) 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) + Request.new(verb, url, client: client, **options).tap do |request| + request.api_auth!(*api_auth) if api_auth + end end private attr_accessor :options, :clients @@ -32,13 +37,15 @@ clients[uri.origin] ||= HTTP.persistent(uri.origin, timeout: timeout) end def default_options { + api_auth: options[:api_auth], + keep_alive: options[:keep_alive], + max_retries: options[:max_retries], on_complete: options[:on_complete], on_error: options[:on_error], - timeout: options[:default_timeout], retry_exceptions: options[:retry_exceptions], - max_retries: options[:max_retries], + timeout: options[:default_timeout], } end end