Netable
open class Netable
extension Netable: Equatable
Undocumented
-
The base URL of your api endpoint.
Declaration
Swift
public var baseURL: URL
-
Headers to be sent with each request.
Declaration
Swift
public var headers: [String : String]
-
Destination that logs will be printed to during network requests.
Declaration
Swift
public var logDestination: LogDestination
-
Create a new instance of
Netable
with a base URL.Declaration
Swift
public init(baseURL: URL, configuration: URLSessionConfiguration = .ephemeral, logDestination: LogDestination = DefaultLogDestination())
Parameters
baseURL
The base URL of your endpoint.
configuration
Configuration such as timeouts and caching policies for the underlying url session.
-
Create and send a new request.
Declaration
Swift
@discardableResult public func request<T>(_ request: T, completion unsafeCompletion: @escaping (Result<T.FinalResource, NetableError>) -> Void) -> RequestIdentifier where T : Request
Parameters
request
The request to send, this has to extend
Request
.completion
Your completion handler for the request.
-
Cancel a specific ongoing request.
Declaration
Swift
open func cancel(byId taskId: RequestIdentifier)
Parameters
request
The request to cancel.
-
Cancel any ongoing requests.
Declaration
Swift
open func cancelAllTasks()
-
Declaration
Swift
public static func == (lhs: Netable, rhs: Netable) -> Bool