You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
550 B

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