Network Layer
-
If you want to use a different networking library, implement this protocol and pass your implementation to
Service.init(...)
.See
See moreURLSessionProvider
andExtensions/Alamofire/Networking-Alamofire.swift
for implementation examples.Declaration
Swift
public protocol NetworkingProvider : NetworkingProviderConvertible
-
A convenience to turn create the appropriate
NetworkingProvider
for a variety of networking configuration objects. Used by theService
initializer.For example, instead of having to do this:
Service(baseURL: "http://foo.bar", networking: URLSessionProvider(session: URLSession(configuration: URLSessionConfiguration.default)))
…you can do this:
Service(baseURL: "http://foo.bar", networking: URLSessionConfiguration.default)
Siesta supports conversion of the following types into a networking provider:
- URLSession
- URLSessionConfiguration
- Alamofire.Manager
…and you can add to the list by writing an extension to implement
See moreNetworkingProviderConvertible
.Declaration
Swift
public protocol NetworkingProviderConvertible
-
Network handling for a single request. Created by a
NetworkingProvider
. Implementations have three responsibilities:- start the request on creation,
- call the closure passed to
NetworkingProvider.startRequest(...)
when the request is complete, and - optionally support cancelling requests in progress.
Declaration
Swift
public protocol RequestNetworking
-
Used by a
NetworkingProvider
implementation to pass the result of a network request back to Siesta.Declaration
Swift
public typealias RequestNetworkingCompletionCallback = (HTTPURLResponse?, Data?, Error?) -> Void
-
Used by
See moreNetworkingProvider
implementations to report request progress.Declaration
Swift
public struct RequestTransferMetrics
-
Uses
URLSessionDataTask
for Siesta networking.This is Siesta’s default networking provider.
See moreDeclaration
Swift
public struct URLSessionProvider : NetworkingProvider
-
Convenience for
See moreNetworkingProvider
implementations that ultimate rely on aURLSessionTask
.Declaration
Swift
public protocol SessionTaskContainer