add custom not found handler

This commit is contained in:
2023-05-11 09:32:18 +02:00
parent 63be7aba60
commit 93f5bd30b9
2 changed files with 79 additions and 23 deletions

View File

@@ -3,6 +3,19 @@ import { HTTPServer } from "../http_server.ts";
const httpServer = new HTTPServer();
httpServer.error((req, _rep) => {
return JSON.stringify(
{
code: Status.NotFound,
message: "Route not found!",
path: req.path,
url: req.url
},
null,
2,
);
})
httpServer.add("GET", "/", (req, rep) => {
rep.status(Status.Teapot)
.header("working", "true")