withHTTPClient(eventLoopGroup:configuration:backgroundActivityLogger:isolation:_:)

Start & automatically shut down a new HTTPClient.

HTTPClient+StructuredConcurrency.swift:27
iOS
13.0+
macOS
10.15+
tvOS
13.0+
watchOS
6.0+
static func withHTTPClient<Return>(eventLoopGroup: any EventLoopGroup = HTTPClient.defaultEventLoopGroup, configuration: Configuration = Configuration(), backgroundActivityLogger: Logger? = nil, isolation: isolated (any Actor)? = #isolation, _ body: (HTTPClient) async throws -> Return) async throws -> Return

This method allows to start & automatically dispose of a HTTPClient following the principle of Structured Concurrency. The HTTPClient is guaranteed to be shut down upon return, whether body throws or not.

This may be particularly useful if you cannot use the shared singleton (shared).