add done promise for middleware

This commit is contained in:
2023-05-11 13:11:14 +02:00
parent b974abff1b
commit 10fb61793f
2 changed files with 25 additions and 5 deletions

View File

@@ -3,9 +3,13 @@ import { HTTPServer } from "../mod.ts";
const httpServer = new HTTPServer();
httpServer.middleware((req) => {
httpServer.middleware(async (req, done) => {
const started = Date.now();
console.log(`${req.method} - ${req.ip()} - ${req.path}`);
})
await done();
const processTime = Date.now() - started;
console.log(`Processed in ${processTime}ms`);
});
httpServer.error((req, _rep) => {
return JSON.stringify(