HTTPResponseWriter

public protocol HTTPResponseWriter : class

HTTPResponseWriter provides functions to create an HTTP response

  • Writer function to create the headers for an HTTP response

    Declaration

    Swift

    func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders, completion: @escaping (Result) -> Void)

    Parameters

    status

    The status code to include in the HTTP response

    headers

    The HTTP headers to include in the HTTP response

    completion

    Closure that is called when the HTTP headers have been written to the HTTP respose

  • Writer function to write a trailer header as part of the HTTP response

    Declaration

    Swift

    func writeTrailer(_ trailers: HTTPHeaders, completion: @escaping (Result) -> Void)

    Parameters

    trailers

    The trailers to write as part of the HTTP response

    completion

    Closure that is called when the trailers has been written to the HTTP response This is not currently implemented

  • Writer function to write data to the body of the HTTP response

    Declaration

    Swift

    func writeBody(_ data: UnsafeHTTPResponseBody, completion: @escaping (Result) -> Void)

    Parameters

    data

    The data to write as part of the HTTP response

    completion

    Closure that is called when the data has been written to the HTTP response

  • Writer function to complete the HTTP response

    Declaration

    Swift

    func done(completion: @escaping (Result) -> Void)

    Parameters

    completion

    Closure that is called when the HTTP response has been completed

  • abort: Abort the HTTP response

    Declaration

    Swift

    func abort()