RouterRequest

public class RouterRequest

Router request.

  • The hostname of the request.

    Declaration

    Swift

    public var hostname: String
  • The port of the request.

    Declaration

    Swift

    public var port: Int
  • 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 var 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
  • url

    The URL. This contains just the path and query parameters starting with ’/’ Use urlComponents for the full URL

    Declaration

    Swift

    public var url : String
  • The URL from the request as URLComponents

    Declaration

    Swift

    public internal(set) var urlComponents = URLComponents()
  • 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 lazy var queryParameters: [String:String] = { [unowned self] in
  • 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.