Comparing version 1.0.2 to 1.0.3
17
index.js
@@ -76,4 +76,9 @@ (function() { | ||
req.pathname = parsed.pathname; | ||
res.jsonResponse = (code, body) => { | ||
res.writeHead(code, { "Content-Type": "application/json" }); | ||
res.jsonResponse = (code, body, headers = false) => { | ||
if (headers) { | ||
res.writeHead(code, headers); | ||
} else { | ||
res.writeHead(code, { "Content-Type": "application/json" }); | ||
} | ||
res.write(JSON.stringify(body)); | ||
@@ -83,4 +88,8 @@ res.end(); | ||
res.response = (code, body) => { | ||
res.writeHead(code, { "Content-Type": "text/html" }); | ||
res.response = (code, body, headers = false) => { | ||
if (headers) { | ||
res.writeHead(code, headers); | ||
} else { | ||
res.writeHead(code, { "Content-Type": "text/html" }); | ||
} | ||
res.write(body); | ||
@@ -87,0 +96,0 @@ res.end(); |
{ | ||
"name": "awebserver", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "this is a simple library to create a web server", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4146
121