Class for building HTTP responses.

Constructors

Properties

headers: Headers = ...
statusCode: number = 200

Methods

  • Ends a streaming response by closing the writer. If not already streaming, it sends the response.

    Returns void

    Error if the response has already been sent.

  • Gets the currently set HTTP status code.

    Returns number

    The HTTP status code.

  • Sends the HTTP response.

    Parameters

    • Optionalvalue: BodyInit

      Optional body content to send with the response.

    Returns void

    Error if the response has already been sent.

  • Sets response headers.

    Parameters

    • arg1: string | Headers | {
          [key: string]: string;
      }

      Header name, object containing headers, or Headers instance.

    • Optionalarg2: string

      Optional header value (if arg1 is a string).

    Returns ResponseBuilder

    The current ResponseBuilder instance for chaining.

    Error if headers have already been sent or if arguments are invalid.

  • Sets the HTTP status code for the response.

    Parameters

    • code: number

      The HTTP status code to set.

    Returns ResponseBuilder

    The current ResponseBuilder instance for chaining.

    Error if headers have already been sent.

  • Writes data to a streaming response.

    Parameters

    • value: BodyInit

      The data to write to the response.

    Returns void

    Error if the response has already been sent.