Sha256: 07fe036b0cb6a60b72f29026a1ae60810f0bc8a30a24c43ddf6722d53a5762f9
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true class EzClient::Client REQUEST_OPTION_KEYS = %i[ api_auth basic_auth cookies headers keep_alive max_retries on_complete on_error on_retry retry_exceptions ssl_context timeout follow error_wrapper ].freeze def initialize(options = {}) self.request_options = options EzClient::CheckOptions.call(options, REQUEST_OPTION_KEYS) end def request(verb, url, **options) options = { **request_options, **options } keep_alive_timeout = options.delete(:keep_alive) api_auth = options.delete(:api_auth) if keep_alive_timeout client = persistent_client_registry.for(url, timeout: keep_alive_timeout) else client = HTTP::Client.new end EzClient::Request.new(verb, url, client: client, **options).tap do |request| request.api_auth!(*api_auth) if api_auth end end def perform(*args, **kwargs) request(*args, **kwargs).perform end def perform!(*args, **kwargs) request(*args, **kwargs).perform! end private attr_accessor :request_options def persistent_client_registry @persistent_client_registry ||= EzClient::PersistentClientRegistry.new end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ezclient-1.7.1 | lib/ezclient/client.rb |
ezclient-1.7.0 | lib/ezclient/client.rb |