NetworkHandler
public protocol NetworkHandler
Defines a protocol to represent all the network functionality that is used to communicate with a RESTful service, the encoding/decoding strategy, the different network requests (get, post, put, delete) and the authorization method.
-
defines the encoding strategy
Declaration
Swift
associatedtype Encoder : TopLevelEncoder -
defines the decoding strategy
Declaration
Swift
associatedtype Decoder : TopLevelDecoder -
the variable that holds the encoder
Declaration
Swift
var encoder: Encoder { get } -
the variable that holds the decoder
Declaration
Swift
var decoder: Decoder { get } -
the variable that holds the authorization method
Declaration
Swift
var authorization: Authorization { get } -
implements a GET request
Declaration
Swift
func get<Element>(on route: URL) -> AnyPublisher<[Element], Error> where Element : Decodable, Element : EncodableParameters
routespecifies the
URLfor the GET requestReturn Value
an
AnyPublisherthat holds a data array and an error -
implements a POST request
Declaration
Swift
func post<Element>(_ element: Element, on route: URL) -> AnyPublisher<Element, Error> where Element : Decodable, Element : EncodableParameters
elementspecifies the element that will be posted
routespecifies the
URLfor the POST requestReturn Value
an
AnyPublisherthat holds the posted element with a specifiedIDand an error -
implements a PUT request
Declaration
Swift
func put<Element>(_ element: Element, on route: URL) -> AnyPublisher<Element, Error> where Element : Decodable, Element : EncodableParameters
elementspecifies the new element that will be edited on the ID of this element
routespecifies the
URL` for the PUT requestReturn Value
an
AnyPublisherthat holds the changed element and an error -
implements a DELETE request
Declaration
Swift
func delete(at route: URL) -> AnyPublisher<Void, Error>Parameters
routespecifies the
URLfor the DELETE requestReturn Value
an
AnyPublisherthat holds an error
View on GitHub
NetworkHandler Protocol Reference