ResultFormat
public enum ResultFormat
Defines the format of the URL response body
-
The body of the response will be JSON decoded
Declaration
Swift
case json
-
Decodes and the provided data into an instance of the provided type, for the current format. If the current format is
.raw, the rawRaw(Data) will be returned.Throws
Error if unable to deocde the data based on the current format.Declaration
Swift
public func decode<T: Decodable>(result: Data, `as` type: T.Type, dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate) throws -> TParameters
resultThe HTTPURLResponse data to decode
typeThe instance to inflate from the decoded data
dateDecodingStrategyThe JSONDecoder.DateDecodingStrategy to use when deserializing Date objects. Defaults to
.deferredToDateReturn Value
An inflated instance of T
-
Returns a new URLRequest with the appropriately applied headers base on this ResultFormat For example, for
.raw, no headers are applied, for.json,application/jsonheaders are set forAcceptandContent-Type, etc.Declaration
Swift
public func headers(for request: URLRequest) -> URLRequestParameters
requestThe request upon which the HTTPHeaders are to be set.
Return Value
A new URLRequest with the set headers.
View on GitHub
ResultFormat Enumeration Reference