Module: Philiprehberger::HttpClient

Defined in:
lib/philiprehberger/http_client.rb,
lib/philiprehberger/http_client/pool.rb,
lib/philiprehberger/http_client/cache.rb,
lib/philiprehberger/http_client/client.rb,
lib/philiprehberger/http_client/errors.rb,
lib/philiprehberger/http_client/metrics.rb,
lib/philiprehberger/http_client/retries.rb,
lib/philiprehberger/http_client/version.rb,
lib/philiprehberger/http_client/response.rb,
lib/philiprehberger/http_client/multipart.rb,
lib/philiprehberger/http_client/connection.rb,
lib/philiprehberger/http_client/cookie_jar.rb,
lib/philiprehberger/http_client/body_encoder.rb

Defined Under Namespace

Modules: BodyEncoder, Connection, Multipart, Retries Classes: Cache, Client, ConfigurationError, CookieJar, Error, HttpError, Metrics, NetworkError, Pool, Response, TimeoutError

Constant Summary collapse

VERSION =
'0.9.1'

Class Method Summary collapse

Class Method Details

.new(**options) ⇒ Client

Convenience constructor that instantiates a new Client.

This is a thin wrapper around new so callers can write ‘Philiprehberger::HttpClient.new(base_url: ’…‘)` without reaching into the nested Client constant.

Parameters:

Returns:

  • (Client)

    a new configured client instance



27
28
29
# File 'lib/philiprehberger/http_client.rb', line 27

def self.new(**options)
  Client.new(**options)
end

.open {|client| ... } ⇒ Object

Block form constructor — creates a Client, yields it, and guarantees cleanup by calling ‘#close` in an `ensure` block when the block exits.

Equivalent to Philiprehberger::HttpClient::Client.open; prefer this form when you want automatic connection pool draining without manually calling ‘#close`.

Parameters:

Yields:

  • (client)

    yields the client instance to the block

Yield Parameters:

  • client (Client)

    the newly created client

Returns:

  • (Object)

    the return value of the block



41
42
43
# File 'lib/philiprehberger/http_client.rb', line 41

def self.open(...)
  Client.open(...)
end