Skip to content

Instantly share code, notes, and snippets.

@twolfson
Created March 25, 2014 01:12
Show Gist options
  • Save twolfson/9753482 to your computer and use it in GitHub Desktop.
Save twolfson/9753482 to your computer and use it in GitHub Desktop.
Modifying eight-track responses
// Inside of a fixed-server
var connections = require('eight-track/lib/connections');
var through = require('through2');
response: function (req, res, next) {
// Forward our request through eight-track
var incomingConn = new connections.IncomingConnection({req: req, res: res});
var externalReq = eightTrack.createExternalRequest(incomingConn);
// Pipe the request through any modifier
externalReq.pipe(through(function (data, enc, cb) {
this.push(data + 'b');
cb();
})).pipe(res);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment