RequestHeaders

public struct RequestHeaders : ExpressibleByDictionaryLiteral, Equatable, Hashable, CustomStringConvertible

RequestHeaders is a value type that stores mapping of header keys an their values. It is sent with a Request and recieved with a RequestResponse

See the the nested Key and Value types for more detailed information. You can create a RequestHeaders using a dictionary litera containing those types.

Initializers

  • Create an empty header with no keys and values

    Declaration

    Swift

    public init()

API

  • Key

    A RequestHeaders.Key is a value type used to describe keys in a header dictionary.

    You can create headers in a few ways:

    • Using any type that conforms to RawRepresentable where RawValue is String
    • Using any type that conforms to CustomStringConvertible
    • Using strings or string literals

    Commonly used values and additional factory methods are declared in an extension to reduce boilerplate and increase type safety.

    See more

    Declaration

    Swift

    public struct Key : ExpressibleByStringLiteral, Equatable, Hashable, CustomStringConvertible
  • A RequestHeaders.Value is a value type used to describe values in a header dictionary.

    You can create values in a few ways:

    • Using any type that conforms to RawRepresentable where RawValue is String
    • Using any type that conforms to CustomStringConvertible
    • Using strings or string literals
    • Using integer literals
    • Using floating point literals

    Commonly used values and additional factory methods are declared in an extension to reduce boilerplate and increase type safety.

    See more

    Declaration

    Swift

    public struct Value : ExpressibleByStringLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, CustomStringConvertible, Equatable, Hashable
  • Retrieve the current value for a key

    Declaration

    Swift

    public func value(for key: Key) -> Value?

    Parameters

    key

    The key

    Return Value

    The value for the key, if one exists

  • Set the value for a key

    Note

    Any previous value wil be discarded

    Declaration

    Swift

    public mutating func set(value: Value?, forKey key: Key)

    Parameters

    value

    The new value

    key

    The key

  • Remove a value for a key

    Declaration

    Swift

    public mutating func removeValue(forKey key: Key)

    Parameters

    key

    The key

  • Returns the result of combining the elements of the sequence using the given closure.

    Throws

    Error from the reduction closure

    Declaration

    Swift

    public func reduce<Result>(_ initialResult: Result,
                               _ nextPartialResult: (Result, (key: Key, value: Value)) throws -> Result) rethrows -> Result

    Parameters

    initialResult

    The value to use as the initial accumulating value. initialResult is passed to nextPartialResult the first time the closure is executed.

    nextPartialResult

    A closure that combines an accumulating value and an element of the sequence into a new accumulating value, to be used in the next call of the nextPartialResult closure or returned to the caller.

    Return Value

    The reduced value

Subscripting

CustomStringConvertible

  • Declaration

    Swift

    public var description: String { get }

ExpressibleByDictionaryLiteral

Equatable

  • Declaration

    Swift

    public static func == (lhs: RequestHeaders, rhs: RequestHeaders) -> Bool

Hashable

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)