Function

func handleError(HttpContext, UInt16)

public func handleError(ctx: HttpContext, code: UInt16): Unit

Description: Specifies a shortcut HTTP request processing function used to return error requests.

Parameters:

func notFound(HttpContext)

public func notFound(ctx: HttpContext): Unit

Description: Specifies a shortcut HTTP request processing function used to return the 404 response.

Parameters:

func upgrade(HttpContext)

public func upgrade(ctx: HttpContext): StreamingSocket

Description: Obtains StreamingSocket in the handler to support protocol upgrade and process CONNECT requests.

  • When this function is called, a response is sent based on ctx.responseBuilder. Only the status code and response header are sent.
  • When this function is called, ctx.request.body is left empty and data can no longer be read through body.read(...). The body data that is not read is stored in the returned StreamingSocket.

Parameters:

Returns:

  • StreamingSocket: underlying connection (or a stream for HTTP/2) used for subsequent read and write

Throws:

  • HttpException: If the underlying connection (or the stream for HTTP/2) fails to be obtained, this exception is thrown.