1
0
Fork 0
mirror of https://github.com/sbrl/powahroot.git synced 2024-11-23 22:53:00 +00:00

Sender: Add .json()

This commit is contained in:
Starbeamrainbowlabs 2022-02-24 01:07:28 +00:00
parent e301dfd226
commit b552134eec
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -37,6 +37,15 @@ class Sender {
html_string(status_code, html_string) {
this.string(status_code, "text/html", html_string);
}
/**
* Sends a given thing of any type as a JSON response.
* @param {number} status_code The status code to return.
* @param {any} obj The thing to send - will be converted to JSON.
* @return {void}
*/
json(status_code, obj) {
this.string(status_code, "application/json", obj);
}
/**
* Sends a given string with a given content-type.
* @param {number} status_code The status code to return.