ResponseDecoder

public class ResponseDecoder
extension ResponseDecoder: TopLevelDecoder

A class responsible for decoding HTTP responses into specified types.

The ResponseDecoder class provides functionality to decode HTTP responses into specified types. It uses the ResponseDecoding decoder to perform the decoding process.

  • Decodes an HTTP response into the specified type.

    Throws

    An error if the decoding process fails.

    Example usage:

    let decoder = ResponseDecoder()
    let decodedValue = try decoder.decode(MyType.self, from: (data: responseData, response: httpResponse))
    

    Declaration

    Swift

    public func decode<T>(_ type: T.Type, from: (data: Data, response: HTTPURLResponse)) throws -> T where T : Decodable

    Parameters

    type

    The type to decode the response into.

    from

    A tuple containing the response data and the HTTP URL response.

    Return Value

    The decoded value of the specified type.