iching-broker-level2/node_modules/union/examples/after/index.js
Christopher Hase b27a419c2f
All checks were successful
ci / build (push) Successful in 1m33s
add http-server part 5
2025-04-09 11:10:36 +02:00

26 lines
550 B
JavaScript

var fs = require('fs'),
path = require('path'),
union = require('../../lib');
var server = union.createServer({
before: [ function (req,res) {
if (req.url === "/foo") {
res.text(201, "foo");
}
} ],
after: [
function LoggerStream() {
var stream = new union.ResponseStream();
stream.once("pipe", function (req) {
console.log({res: this.res.statusCode, method: this.req.method});
});
return stream;
}
]
});
server.listen(9080);
console.log('union running on 9080');