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:
parent
e301dfd226
commit
b552134eec
1 changed files with 9 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue