Skip to content

Instantly share code, notes, and snippets.

@Marak
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marak/dae1d76156e19dd3e3f8 to your computer and use it in GitHub Desktop.
Save Marak/dae1d76156e19dd3e3f8 to your computer and use it in GitHub Desktop.
hook.io example microservice for composing two hooks together with stream.pipe()
// Connect two Hooks together using .pipe()
module['exports'] = function pipeHook (hook) {
// hook.open will create a stream to the echo hook
// hook.open is for convience. Any stream will work.
var stream = hook.open('https://hook.io/Marak/examples-helloWorld');
// Once we have created a stream to helloWorld,
// pipe that stream to the client.
// This techinque can be used on any streaming interace
stream.pipe(hook.res);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment