mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-12 12:56:38 +00:00
server: return detailed information
This commit is contained in:
parent
2517686f8c
commit
69d338862b
1 changed files with 2 additions and 2 deletions
|
|
@ -15,13 +15,13 @@ const serve = async (port: number) => {
|
||||||
console.log(`Request on address '${req.url}'`);
|
console.log(`Request on address '${req.url}'`);
|
||||||
|
|
||||||
if (parseURL(req.url) === "") {
|
if (parseURL(req.url) === "") {
|
||||||
return req.respond({ body: sayRandomHello() });
|
return req.respond({ body: JSON.stringify(sayRandomHello()) });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const value = parseInt(parseURL(req.url), 10);
|
const value = parseInt(parseURL(req.url), 10);
|
||||||
const id = new ID(value);
|
const id = new ID(value);
|
||||||
return req.respond({ body: sayHello(id) });
|
return req.respond({ body: JSON.stringify(sayHello(id)) });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return req.respond({ body: error.message });
|
return req.respond({ body: error.message });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue