add example for multiple preprocessors

This commit is contained in:
HorizonCode 2023-05-12 15:19:02 +02:00
parent 1376fbdeba
commit b2e357227c

View File

@ -17,6 +17,13 @@ const JOKES = [
const httpServer = new HTTPServer(); const httpServer = new HTTPServer();
// Add as many preprocessors as you want
httpServer.preprocessor((req, _rep) => {
if (req.resourceRequest) {
console.log(`Requested resource ${req.path}`);
}
});
httpServer.preprocessor((_req, rep) => { httpServer.preprocessor((_req, rep) => {
rep.header("Access-Control-Allow-Origin", "*"); rep.header("Access-Control-Allow-Origin", "*");
}); });