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.A RawHttpResponse object.
StaticcreateFactory 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.
Partial options to configure the HTTP response.
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' } }
Wrapper for HTTP raw responses in Tencent SCF.
The
RawHttpResponseWrapperis responsible for constructing and returning a raw HTTP response that conforms to the expected structure for Tencent SCF. It implements theIRawResponseWrapperinterface, ensuring compatibility with the Stone.js framework.