socketioMEANseed/www/node_modules/union/examples/after/index.js
www/node_modules/union/examples/after/index.jsRaw
1var fs = require('fs'),
2 path = require('path'),
3 union = require('../../lib');
4
5var server = union.createServer({
6 before: [ function (req,res) {
7 if (req.url === "/foo") {
8 res.text(201, "foo");
9 }
10 } ],
11 after: [
12 function LoggerStream() {
13 var stream = new union.ResponseStream();
14
15 stream.once("pipe", function (req) {
16 console.log({res: this.res.statusCode, method: this.req.method});
17 });
18
19 return stream;
20 }
21 ]
22});
23
24server.listen(9080);
25console.log('union running on 9080');
26