Stone.js API
    Preparing search index...

    Wrapper for HTTP raw responses in Tencent SCF.

    The RawHttpResponseWrapper is responsible for constructing and returning a raw HTTP response that conforms to the expected structure for Tencent SCF. It implements the IRawResponseWrapper interface, ensuring compatibility with the Stone.js framework.

    Implements

    Index
    • Constructs and returns the raw HTTP response.

      The respond method generates a RawHttpResponse object based on the provided options. If any required fields are missing, it assigns default values:

      • statusCode: Defaults to 500.

      Returns RawHttpResponseOptions

      A RawHttpResponse object.

      const responseWrapper = RawHttpResponseWrapper.create({ body: 'Hello, world!', statusCode: 200 });
      const response = responseWrapper.respond();
      console.log(response); // { statusCode: 500, statusMessage: '', body: 'Hello, world!', headers: undefined }
    • Factory method to create an instance of RawHttpResponseWrapper.

      This method accepts partial response options, allowing the user to configure only the required fields. It initializes the wrapper with these options.

      Parameters

      Returns RawHttpResponseWrapper

      A new instance of RawHttpResponseWrapper.

      const responseWrapper = RawHttpResponseWrapper.create({
      statusCode: 200,
      body: { message: 'Success' },
      headers: { 'Content-Type': 'application/json' }
      });

      const response = responseWrapper.respond();
      console.log(response); // { statusCode: 200, body: '{"message":"Success"}', headers: { 'Content-Type': 'application/json' } }