HttpClient
public enum HttpClient
Factory helper for creating HTTP client instances.
This enum provides a convenient factory method for creating HTTP clients without needing to reference the concrete implementation type directly.
Example:
let client = HttpClient.createClient { config in
config.timeout = 30.0
config.onRequest { req in
req.setHeader(name: "User-Agent", value: "MyApp/1.0")
}
}
-
Creates a new HTTP client instance with optional configuration.
This factory method creates a URLSession-based HTTP client with sensible defaults. You can customize the client behavior using the configuration closure.
Declaration
Swift
public static func createClient( _ configure: (HttpClientConfig) -> Void = { _ in } ) -> any HttpClientProtocolParameters
configureA closure that configures the HTTP client.
Return Value
A configured HTTP client instance conforming to
HttpClientProtocol.
View on GitHub