RouterResponse

public class RouterResponse
  • Set of cookies to return with the response

    Declaration

    Swift

    public var cookies = [String: HTTPCookie]()
  • Optional error value

    Declaration

    Swift

    public var error: Swift.Error?
  • Undocumented

    Declaration

    Swift

    public class RouterResponse
  • Undocumented

    Declaration

    Swift

    public class RouterResponse
  • Ends the response

    Throws

    ???

    Declaration

    Swift

    public func end() throws
  • Sends a string

    Parameter

    Parameter str: the string to send

    Returns

    this RouterResponse

    Declaration

    Swift

    public func send(_ str: String) -> RouterResponse

    Parameters

    str

    the string to send

    Return Value

    this RouterResponse

  • Sends data

    Parameter

    Parameter data: the data to send

    Returns

    this RouterResponse

    Declaration

    Swift

    public func send(data: Data) -> RouterResponse

    Parameters

    data

    the data to send

    Return Value

    this RouterResponse

  • Sends a file

    Parameter

    Parameter fileName: the name of the file to send.

    Returns

    this RouterResponse

    Note

    Sets the Content-Type header based on the extension of the file. If the fileName is relative, it is relative to the current directory.

    Declaration

    Swift

    public func send(fileName: String) throws -> RouterResponse

    Parameters

    fileName

    the name of the file to send.

    Return Value

    this RouterResponse

  • Sends JSON

    Parameter

    Parameter json: the JSON object to send

    Returns

    this RouterResponse

    Declaration

    Swift

    public func send(json: JSON) -> RouterResponse

    Parameters

    json

    the JSON object to send

    Return Value

    this RouterResponse

  • Sends JSON with JSONP callback

    Parameter

    Parameter json: the JSON object to send

    Parameter

    Parameter callbackthe name of the URL query parameter whose value contains the JSONP callback function

    Throws

    JSONPError.invalidCallbackName if the the callback query parameter of the request URL is missing or its value is empty or contains invalid characters (the set of valid characters is the alphanumeric characters and []$._).

    Returns

    this RouterResponse

    Declaration

    Swift

    public func send(jsonp: JSON, callbackParameter: String = "callback") throws -> RouterResponse

    Parameters

    json

    the JSON object to send

    callbackParameter

    the name of the URL query parameter whose value contains the JSONP callback function

    Return Value

    this RouterResponse

  • Set the status code

    Parameter

    Parameter status: the status code object

    Returns

    this RouterResponse

    Declaration

    Swift

    public func status(_ status: HTTPStatusCode) -> RouterResponse

    Parameters

    status

    the status code object

    Return Value

    this RouterResponse

  • Sends the HTTP status code

    Parameter

    Parameter status: the HTTP status code

    Throws

    ???

    Returns

    this RouterResponse

    Declaration

    Swift

    public func send(status: HTTPStatusCode) throws -> RouterResponse

    Parameters

    status

    the HTTP status code

    Return Value

    this RouterResponse

  • Redirect to path with status code

    Parameter

    the path for the redirect

    Parameter

    the status code for the redirect

    Returns

    this RouterResponse

    Declaration

    Swift

    public func redirect(_ path: String, status: HTTPStatusCode = .movedTemporarily) throws -> RouterResponse

    Return Value

    this RouterResponse

  • Undocumented

    Declaration

    Swift

    public class RouterResponse
  • Sets headers and attaches file for downloading

    Parameter

    Parameter download: the file to download

    Declaration

    Swift

    public func send(download: String) throws

    Parameters

    download

    the file to download

  • Sets the pre-flush lifecycle handler and returns the previous one

    Parameter

    Parameter newOnEndInvoked: The new pre-flush lifecycle handler

    Returns

    The old pre-flush lifecycle handler

    Declaration

    Swift

    public func setOnEndInvoked(_ newOnEndInvoked: LifecycleHandler) -> LifecycleHandler

    Parameters

    newOnEndInvoked

    The new pre-flush lifecycle handler

    Return Value

    The old pre-flush lifecycle handler

  • Sets the written data filter and returns the previous one

    Parameter

    Parameter newWrittenDataFilter: The new written data filter

    Returns

    The old written data filter

    Declaration

    Swift

    public func setWrittenDataFilter(_ newWrittenDataFilter: WrittenDataFilter) -> WrittenDataFilter

    Parameters

    newWrittenDataFilter

    The new written data filter

    Return Value

    The old written data filter

  • Performs content-negotiation on the Accept HTTP header on the request, when present. It uses request.accepts() to select a handler for the request, based on the acceptable types ordered by their quality values. If the header is not specified, the default callback is invoked. When no match is found, the server invokes the default callback if exists, or responds with 406 “Not Acceptable”. The Content-Type response header is set when a callback is selected.

    Parameter

    Parameter callbacks: a dictionary that maps content types to handlers

    Declaration

    Swift

    public func format(callbacks: [String : ((RouterRequest, RouterResponse) -> Void)]) throws

    Parameters

    callbacks

    a dictionary that maps content types to handlers