HeadersContainer
public class HeadersContainer
extension HeadersContainer: Collection
A class that abstracts out the HTTP header APIs of the ServerRequest and
ServerResponse protocols.
Usage Example:
public var headers: HeadersContainer { return httpParser?.headers ?? HeadersContainer() }
-
Creates an instance of
HeadersContainer.Usage Example:
let headers = HeaderContainer()Declaration
Swift
public init() -
Access the value of a HTTP header using subscript syntax.
Usage Example:
let subscript: [String]? = headers.subscript(key: "key")Declaration
Swift
public subscript(key: String) -> [String]? { get set }Parameters
keyThe 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.
Usage Example:
header.append(key, value: arrayOfvalues)Declaration
Swift
public func append(_ key: String, value: [String])Parameters
keyThe HTTP header key
valueAn array of Strings to add as values of the HTTP header.
-
Append values to an HTTP header.
Usage Example:
header.append(key, value: value)Declaration
Swift
public func append(_ key: String, value: String)Parameters
keyThe HTTP header key
valueAn String to br appended to the value of the HTTP header.
-
Remove all of the headers.
Usage Example:
header.removeAll()Declaration
Swift
public func removeAll() -
Declaration
Swift
public typealias Index = DictionaryIndex<String, (key: String, value: [String])> -
The starting index of the
HeadersContainercollectionDeclaration
Swift
public var startIndex: Index { get } -
The ending index of the
HeadersContainercollectionDeclaration
Swift
public var endIndex: Index { get } -
Get a (key value) tuple from the
HeadersContainercollection at the specified position.Usage Example:
header.subscript(position: index)Declaration
Swift
public subscript(position: Index) -> (key: String, value: [String]) { get }Parameters
positionThe position in the
HeadersContainercollection of the (key, value) tuple to return.Return Value
A (key, value) tuple.
-
Get the next index in the
HeadersContainercollection after the one specified.Usage Example:
header.index(after: index)Parameters
afterThe Index whose successor is to be returned.
Return Value
The Index in the
HeadersContainercollection after the one specified.
View on GitHub
HeadersContainer Class Reference