class

Vug::HttpClientFactory

Inherits Reference < Object

HTTP client factory. Creates configured HTTP::Client instances for making requests.

Constructors

new(config : Config)
Source

Instance methods

create_client(uri : URI, read_timeout : Time::Span, connect_timeout : Time::Span | Nil = nil, write_timeout : Time::Span | Nil = nil) : HTTP::Client

Create a new HTTP client with custom timeout settings. Useful for requests that may need longer timeouts (e.g., slow servers).

Source
create_client(uri : URI) : HTTP::Client

Create a new HTTP client configured with the current settings.

Source
with_client(uri : URI, timeout : Time::Span | Nil = nil, & : HTTP::Client -> T) : T forall T

Release/close a client after use. In Crystal, HTTP::Client handles connection pooling internally, so we just close the client to ensure clean state. Execute a block with a managed HTTP client lifecycle. Creates a client, yields it, and ensures it is closed afterward.

Source