RouterRequest
public class RouterRequest
Router request.
-
The hostname of the request.
Declaration
Swift
public private(set) lazy var hostname: String = { [unowned self] () in
-
The port of the request.
Declaration
Swift
public private(set) lazy var port: Int = { [unowned self] () in
-
The domain name of the request.
Declaration
Swift
public private(set) lazy var domain: String = { [unowned self] in
-
The subdomains string array of request.
Declaration
Swift
public private(set) lazy var subdomains: [String] = { [unowned self] in
-
The HTTP version of the request.
Declaration
Swift
public let httpVersion: HTTPVersion
-
The method of the request.
Declaration
Swift
public let method: RouterMethod
-
The parsed URL.
Declaration
Swift
public let parsedURL: URLParser
-
The router as a String.
Declaration
Swift
public internal(set) var route: String?
-
The currently matched section of the URL.
Declaration
Swift
public internal(set) var matchedPath = ""
-
The original URL as a string.
Declaration
Swift
public var originalURL: String
-
The URL.
Declaration
Swift
public let url: String
-
List of HTTP headers with simple String values.
Declaration
Swift
public let headers: Headers
-
IP address string of server.
Declaration
Swift
public var remoteAddress: String
-
Set of parsed cookies.
Declaration
Swift
public var cookies: [String: HTTPCookie]
-
List of URL parameters.
Declaration
Swift
public internal(set) var parameters: [String:String] = [:]
-
List of query parameters.
Declaration
Swift
public var queryParameters: [String:String]
-
User info.
Declaration
Swift
public var userInfo: [String: Any] = [:]
-
Body of the message.
Declaration
Swift
public internal(set) var body: ParsedBody?
-
Read the body of the request as Data.
Parameter
Parameter into: Data object in which the body of the request is returned.Throws
Socket.Error if an error occurred while reading from a socket.Returns
the number of bytes read.Declaration
Swift
public func read(into data: inout Data) throws -> Int
Parameters
into
Data object in which the body of the request is returned.
Return Value
the number of bytes read.
-
Read the body of the request as String.
Throws
Socket.Error if an error occurred while reading from a socket.Returns
the String with the request body.Declaration
Swift
public func readString() throws -> String?
Return Value
the String with the request body.
-
Check if passed in types are acceptable based on the request’s header field specified in the first parameter.
Parameter
Parameter header: name of request’s header field to be checked.Parameter
Parameter types: array of content/mime type strings.Returns
most acceptable type or nil if there are none.Declaration
Swift
public func accepts(header: String = "Accept", types: [String]) -> String?
Parameters
header
name of request’s header field to be checked.
types
array of content/mime type strings.
Return Value
most acceptable type or nil if there are none.
-
Check if passed in types are acceptable based on the request’s header field specified in the first parameter.
Parameter
Parameter header: name of request’s header field to be checked.Parameter
Parameter types: content/mime type strings.Returns
most acceptable type or nil if there are none.Declaration
Swift
public func accepts(header: String = "Accept", types: String...) -> String?
Parameters
header
name of request’s header field to be checked.
types
content/mime type strings.
Return Value
most acceptable type or nil if there are none.
-
Check if passed in types are acceptable based on the request’s header field specified in the first parameter.
Parameter
Parameter header: name of request’s header field to be checked.Parameter
Parameter type: content/mime type string.Returns
most acceptable type or nil if there are none.Declaration
Swift
public func accepts(header: String = "Accept", type: String) -> String?
Parameters
header
name of request’s header field to be checked.
type
content/mime type string.
Return Value
most acceptable type or nil if there are none.