add reply to middlewareResponse

This commit is contained in:
2023-05-12 11:56:48 +02:00
parent 301a6d2c3d
commit 1c668e5892
2 changed files with 6 additions and 4 deletions

View File

@@ -4,7 +4,8 @@ import { HTTPServer } from "../mod.ts";
const httpServer = new HTTPServer();
httpServer.middleware(async (req, done) => {
httpServer.middleware(async (req, rep, done) => {
rep.header("Access-Control-Allow-Origin", "*");
console.log(`${req.method} - ${req.remoteIpAddr} - ${req.path}`);
const processTime = await done();
console.log(`Processed in ${prettyTime(processTime)}`);
@@ -23,7 +24,7 @@ httpServer.error((req, _rep) => {
);
});
httpServer.add("GET", "/", (req, rep) => {
httpServer.get("/", (req, rep) => {
rep.status(Status.Teapot)
.header("working", "true")
.type("application/json")
@@ -37,7 +38,7 @@ httpServer.add("GET", "/", (req, rep) => {
};
});
httpServer.add("GET", "/api/user/:userId", (req, rep) => {
httpServer.get("/api/user/:userId", (req, rep) => {
rep.status(Status.Teapot)
.type("application/json");