RequestHeader
@propertyWrapper
public struct RequestHeader<T> where T : RequestHeaderValue
extension RequestHeader: Encodable where T: Encodable
A property wrapper that provides a convenient way to handle HTTP headers in a request.
Example usage:
@RequestHeader var header: String
This property wrapper can be used to manage HTTP headers in a request.
-
The custom name of the header item, can be nil.
This property holds the custom name of the header item, which can be nil.
Declaration
Swift
public var name: String?
-
The wrapped value representing the header value.
This property holds the wrapped value representing the header value.
Declaration
Swift
public var wrappedValue: T
-
Initializes a new instance of
RequestHeader
with the specified wrapped value.Example usage:
@RequestHeader var header: String = "value"
Declaration
Swift
public init(wrappedValue: T)
Parameters
wrappedValue
The wrapped value representing the header value.
-
Initializes a new instance of
RequestHeader
with the specified name and default value.Example usage:
@RequestHeader(name: "Custom-Header") var header: String = "value"
Declaration
Swift
public init(name: String? = nil, defaultValue: T)
Parameters
name
The custom name of the header item, can be nil.
defaultValue
The default value representing the header value.
-
Initializes a new instance of
RequestHeader
with the specified name and an empty string as the default value.Example usage:
@RequestHeader(name: "Custom-Header") var header: String
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the header item, can be nil.
-
Initializes a new instance of
RequestHeader
with the specified name and a nil value as the default value.Example usage:
@RequestHeader(name: "Custom-Header") var header: String?
Declaration
Swift
public init(name: String?)
Parameters
name
The custom name of the header item, can be nil.