add done promise for middleware

This commit is contained in:
HorizonCode committed 2023-05-11 13:11:14 +02:00
1 parent b974abff1b
commit 10fb61793f
2 files changed
+25 -5

No files matched your search

+6 -2
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(