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()
-
writeHeader(status:headers:)
Extension methodConvenience function to write the headers for an HTTP response without a completion handler
Declaration
Swift
public func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders)
-
writeHeader(status:)
Extension methodConvenience function to write a HTTP response with no headers or completion handler
Declaration
Swift
public func writeHeader(status: HTTPResponseStatus)
-
writeTrailer(_:)
Extension methodConvenience function to write a trailer header as part of the HTTP response without a completion handler
Declaration
Swift
public func writeTrailer(_ trailers: HTTPHeaders)
-
writeBody(_:)
Extension methodConvenience function for writing
data
to the body of the HTTP response without a completion handler.See
writeBody(_:completion:)Declaration
Swift
public func writeBody(_ data: UnsafeHTTPResponseBody)
-
done()
Extension methodConvenience function to complete the HTTP response without a completion handler.
See
done(completion:)Declaration
Swift
public func done()