Resolved issue 7

This commit is contained in:
Alex Rennie-Lis 2024-04-07 19:02:03 +01:00
parent d762fc1c15
commit 48d4c73ca3

View File

@ -97,14 +97,15 @@ listeners.accounting.socket.bind (config.ports.radius_accounting);
// HTTP listener
const respond = (res, content, status) => {
if (typeof (content) == "string") {
res.write (content);
var type = "text/plain";
if (typeof (content) != "string") {
content = JSON.stringify (content);
type = "application/json";
}
else {
res.write (JSON.stringify (content));
}
res.statusCode = status;
res.end ();
res.writeHead (status, {
"Content-Type": type,
"Content-Length": content.length
}).end (content);
};
http.createServer (function (req, res) {