ResponseHeader
@propertyWrapper
public struct ResponseHeader<DecodingStrategy> where DecodingStrategy : ResponseHeaderDecodingStrategy
extension ResponseHeader: Decodable where DecodingStrategy.RawValue: Decodable
A property wrapper that provides a convenient way to handle HTTP headers in a response.
The ResponseHeader struct is a property wrapper that allows you to decode HTTP headers from a response
using a specified decoding strategy. It wraps the DecodingStrategy.RawValue type and provides a default value.
Example usage:
@ResponseHeader<CustomDecodingStrategy> var header: String
-
The wrapped value representing the decoded header value.
This property holds the
DecodingStrategy.RawValuevalue that is managed by this property wrapper.Declaration
Swift
public var wrappedValue: DecodingStrategy.RawValue -
Initializes a new instance of
ResponseHeaderwith the specified wrapped value.Example usage:
@ResponseHeader<CustomDecodingStrategy> var header: String = "value"Declaration
Swift
public init(wrappedValue: DecodingStrategy.RawValue)Parameters
wrappedValueThe wrapped value representing the decoded header value.
-
Initializes a new instance of
ResponseHeaderby decoding from the given decoder.This initializer uses the specified decoding strategy to decode the header value from the given decoder.
Throws
An error if the decoding process fails.Example usage:
let decoder = JSONDecoder() let header = try ResponseHeader<CustomDecodingStrategy>(from: decoder)Declaration
Swift
public init(from decoder: Decoder) throwsParameters
decoderThe decoder to read data from.
View on GitHub