Convert several methods to async await.

This commit is contained in:
Brent Simmons
2024-04-09 19:27:51 -07:00
parent 3771f58013
commit 9c1e372f90
3 changed files with 268 additions and 470 deletions

View File

@@ -66,6 +66,21 @@ extension Transport {
}
}
public func send<P: Encodable & Sendable>(request: URLRequest, method: String, payload: P) async throws {
try await withCheckedThrowingContinuation { continuation in
self.send(request: request, method: method, payload: payload) { result in
switch result {
case .success:
continuation.resume()
case .failure(let error):
continuation.resume(throwing: error)
}
}
}
}
/**
Sends the specified HTTP method with a JSON payload.
*/