Class: Nonnative::HTTPClient

Inherits:
Object
  • Object
show all
Defined in:
lib/nonnative/http_client.rb

Overview

Minimal RestClient-based HTTP client with consistent exception handling.

This class is intended to be subclassed by higher-level clients (for example Observability). It provides protected helpers for common HTTP verbs and a retry wrapper.

Error handling behavior:

  • Timeouts and broken connections (see #initialize) are re-raised so callers can handle them explicitly.

  • Other RestClient::Exception errors return the underlying response object.

See Also:

Direct Known Subclasses

Observability

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ HTTPClient

Returns a new instance of HTTPClient.

Parameters:

  • host (String)

    base URL used to build request URLs (e.g. ‘“127.0.0.1:8080”`)



17
18
19
20
21
22
23
# File 'lib/nonnative/http_client.rb', line 17

def initialize(host)
  @host = host
  @exceptions = [
    RestClient::Exceptions::Timeout,
    RestClient::ServerBrokeConnection
  ]
end