httpiped-stream
abstracted transform streams for httpiped
httpiped-stream allows you to create a Transform stream suitable for use with httpiped. The use case of this is to provide a similar method of creating "middleware" like Express.
Installation
npm install httpiped-stream
Example
var HTTPiped = require("httpiped");
var crStream = require("httpiped-stream").createStream;
var http = require("http");
var server = http.createServer();
var stream = new HTTPiped(server);
var setData = crStream(function (req, res, done) {
req.someData = "Hello, world!\n";
done();
});
var logger = crStream(function (req, res, done) {
console.log("request from", req.connection.remoteAddress);
done();
});
var handler = crStream(function (req, res, done) {
res.end(req.someData);
done();
});
stream.pipe(setData)
.pipe(logger)
.pipe(handler);
server.listen(8050);