Constructor
new RouterResponse(cfResObj)
Parameters:
Name | Type | Description |
---|---|---|
cfResObj | CloudFrontResponse | | CloudFront response object (optional). |
- Source
Methods
data() → {CloudFrontResponse}
Return the CloudFront response data.
- Source
Returns:
- Type:
- CloudFrontResponse
json(data) → {String}
Return the data as JSON.
Parameters:
Name | Type | Description |
---|---|---|
data | Object | Data as object. |
- Source
Returns:
- Type:
- String
setHeader(key, value)
Set HTTP response header.
Parameters:
Name | Type | Description |
---|---|---|
key | String | HTTP header key. |
value | String | HTTP header value. |
- Source
Example
res.setHeader('Content-Type', 'text/html');
status(code) → {Object.<function()>}
Return the AWS response data.
Parameters:
Name | Type | Description |
---|---|---|
code | Number | HTTP status code. |
- Source
Returns:
- Type:
- Object.<function()>
Example
res.setHeader('Content-Type', 'mime/type');
res.status(200).send(value);
..
res.setHeader('Content-Type', 'application/json');
res.status(200).json({hello: 'world'});
..
res.setHeader('Content-Type', 'text/html');
res.status(200).text('Hello World');
..
res.setHeader('Content-Type', 'image/jpeg; charset=utf-8');
res.status(200).data(buffer);
text(body) → {String}
Return the body text.
Parameters:
Name | Type | Description |
---|---|---|
body | String | Body as string. |
- Source
Returns:
- Type:
- String