Created
March 25, 2014 01:12
-
-
Save twolfson/9753482 to your computer and use it in GitHub Desktop.
Modifying eight-track responses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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