ServerResponse

public protocol ServerResponse : AnyObject

The ServerResponse protocol allows responses to be abstracted across different networking protocols in an agnostic way to the Kitura project Router.

  • The status code to send in the HTTP response.

    Declaration

    Swift

    var statusCode: HTTPStatusCode? { get set }
  • The headers to send back as part of the HTTP response.

    Declaration

    Swift

    var headers: HeadersContainer { get }
  • Add a string to the body of the HTTP response.

    Throws

    Socket.error if an error occurred while writing to the socket

    Declaration

    Swift

    func write(from string: String) throws

    Parameters

    string

    The String data to be added.

  • Add bytes to the body of the HTTP response.

    Throws

    Socket.error if an error occurred while writing to the socket

    Declaration

    Swift

    func write(from data: Data) throws

    Parameters

    data

    The Data struct that contains the bytes to be added.

  • Add a string to the body of the HTTP response and complete sending the HTTP response

    Throws

    Socket.error if an error occurred while writing to the socket

    Declaration

    Swift

    func end(text: String) throws

    Parameters

    text

    The String to add to the body of the HTTP response.

  • Complete sending the HTTP response

    Throws

    Socket.error if an error occurred while writing to a socket

    Declaration

    Swift

    func end() throws
  • Reset this response object back to it’s initial state

    Declaration

    Swift

    func reset()