-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APIClient v2 #36
Comments
With the new APIs, you'll be able to use func send<Response>(
_ request: Request<Response>,
cachePolicy: URLRequest.CachePolicy = .useProtocolCachePolicy
) async throws -> Response where Response: Decodable |
Another options to cover the latest requirement: public struct RequestOptions {
public var cachePolicy: URLRequest.CachePolicy?
public var timeoutInterval: TimeInterval?
// Etc
}
public protocol APIClient2 {
public func send<T: Decodable>(
_ request: Request<T>,
options: RequestOptions = .init(),
delegate: URLSessionDataDelegate? = nil
) async throws -> Response<T>
} |
Going with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm considering redesigning the
APIClient
public API for Get 1.0. It was initially designed to accommodate only the most basic scenarios, but I'd like it to be more flexible. Here is a draft of a new API.Main Changes
URL
andURLRequest
in addition toRequest
URLSessionDataDelegate
for progress reporting, per-task auth, etc.Response<Data>
andResponse<String>
support fromsend(_:)
. If you usesend(_:)
, they'll just use the defaultDecodable
implementation for these types. You'll need to calldata(for:)
orstring(for:)
instead – faster, more discoverable, self-documentingThe text was updated successfully, but these errors were encountered: