Skip to content

Instantly share code, notes, and snippets.

@momohuri
Last active August 29, 2015 13:56
Show Gist options
  • Save momohuri/9240910 to your computer and use it in GitHub Desktop.
Save momohuri/9240910 to your computer and use it in GitHub Desktop.
server.route({
method: 'GET',
path: '/hello',
handler: function (request, reply) {
var writestream = new stream.Stream()
writestream.writable = true;
writestream.write = function (data) {
return true;
}
writestream.end = function (data) {
}
writestream.write({number: 1});
var readstream = new stream.Stream()
readstream.readable = true;
writestream.pipe(readstream) ;
reply(readstream);
}
});
@nlf
Copy link

nlf commented Feb 26, 2014

server.route({
    method: 'get',
    path: '/',
    handler: function (request, reply) {
        var readable = new Stream.Readable();
        readable._read = function () {
            this.push('have some data');
            this.push(null);
        };

        reply(readable);
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment