DefaultHeaderStrategyOptional

public struct DefaultHeaderStrategyOptional<RawValue> : ResponseHeaderDecodingStrategy where RawValue : Decodable, RawValue : Encodable

A default strategy for decoding optional response headers.

The DefaultHeaderStrategyOptional struct provides a default strategy for decoding optional response headers by checking if the header key is present in the response decoder.

Example usage:

@ResponseHeaderWrapper<Header, DefaultHeaderStrategyOptional> var header: Header?
  • Decodes the response header value from the given decoder.

    Throws

    An error if the header key is missing or the decoder is not a response decoder.

    Declaration

    Swift

    public static func decode(decoder: Decoder) throws -> RawValue?

    Parameters

    decoder

    The decoder to decode the header value from.

    Return Value

    The decoded header value, or nil if the header key is missing or the decoder is not a response decoder.