HeadersContainer
public class HeadersContainer
extension HeadersContainer: Collection
A class that abstracts out the HTTP header APIs of the ServerRequest
and
ServerResponse
protocols.
-
Create an instance of
HeadersContainer
Declaration
Swift
public init()
-
Access the value of a HTTP header using subscript syntax.
Declaration
Swift
public subscript(key: String) -> [String]? { get set }
Parameters
key
The HTTP header key
Return Value
An array of strings representing the set of values for the HTTP header key. If the HTTP header is not found, nil will be returned.
-
Append values to an HTTP header
Declaration
Swift
public func append(_ key: String, value: [String])
Parameters
key
The HTTP header key
value
An array of strings to add as values of the HTTP header
-
Append values to an HTTP header
Declaration
Swift
public func append(_ key: String, value: String)
Parameters
key
The HTTP header key
value
A string to be appended to the value of the HTTP header
-
Remove all of the headers
Declaration
Swift
public func removeAll()
-
Declaration
Swift
public typealias Index = DictionaryIndex<String, (key: String, value: [String])>
-
The starting index of the
HeadersContainer
collectionDeclaration
Swift
public var startIndex: Index { get }
-
The ending index of the
HeadersContainer
collectionDeclaration
Swift
public var endIndex: Index { get }
-
Get a (key value) tuple from the
HeadersContainer
collection at the specified position.Declaration
Swift
public subscript(position: Index) -> (key: String, value: [String]) { get }
Parameters
position
The position in the
HeadersContainer
collection of the (key, value) tuple to return.Return Value
A (key, value) tuple.