URLSessionNetworkHandler
public class URLSessionNetworkHandler<Encoder: TopLevelEncoder, Decoder: TopLevelDecoder>: NetworkHandler
where Encoder.Output == Data, Decoder.Input == Data
URLSessionNetworkHandler conforms to the NetworkHandler protocol and represents an implementation of the different network requests
-
specifies the encoding strategy
Declaration
Swift
public let encoder: Encoder -
specifies the decoding strategy
Declaration
Swift
public let decoder: Decoder -
specifies the authorization method
Declaration
Swift
public let authorization: Authorization -
initialization of the
URLSessionNetworkHandlerwith.noneas defaultAuthorizationvariableDeclaration
Swift
public init(encoder: Encoder, decoder: Decoder, authorization: Authorization = .none) -
performs a PUT request on the specified
URLand replaces the element located on theURLwith theElementthat is passed inDeclaration
Swift
public func put<Element>(_ element: Element, on route: URL) -> AnyPublisher<Element, Error> where Element : Decodable, Element : EncodableParameters
elementthe element that is used to replace the old element
routethe
URLwhere the old element is locatedReturn Value
an
AnyPublisherthat holds the newElementand anError -
performs a GET request on the specified
URLDeclaration
Swift
public func get<Element>(on route: URL) -> AnyPublisher<[Element], Error> where Element : Decodable, Element : EncodableParameters
routethe
URLwhere the GET request gets theElementsReturn Value
an
AnyPublisherthat holds the returned array ofElementsand anError -
performs a POST request on the specified
URLDeclaration
Swift
public func post<Element>(_ element: Element, on route: URL) -> AnyPublisher<Element, Error> where Element : Decodable, Element : EncodableParameters
elementthe new
Elementthat is postedroutethe
URLfor the newElementReturn Value
an
AnyPublisherthat holds the newElementand anError -
performs a DELETE request on the specified
URLDeclaration
Swift
public func delete(at route: URL) -> AnyPublisher<Void, Error>Parameters
routethe
URLwhere the removal happensReturn Value
an
AnyPublisherthat holds aVoidtype and anError
View on GitHub
URLSessionNetworkHandler Class Reference