Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created February 16, 2011 05:06
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 TooTallNate/828899 to your computer and use it in GitHub Desktop.
Save TooTallNate/828899 to your computer and use it in GitHub Desktop.
var http = require('http');
var Stack = require('stack');
var stack1 = Stack(
// Layers...
);
stack1.errorHandler = function(req, res, err) {
res.writeHead(404);
res.end('Not Found Custom');
}
var stack2 = Stack(
// Other Layers...
);
stack2.errorHandler = function(req, res, err) {
if (err) {
res.setHeader('error', err.stack);
}
res.writeHead(500);
res.end("ERROR Custom");
}
var stack3 = Stack(
// Possibly even more layers...
);
// Will use the default error handler: `Stack.errorHandler`
// i.e. the regular API, still backwards-compatible.
// set 'em up!
http.createServer(stack1).listen(8081);
http.createServer(stack2).listen(8082);
http.createServer(stack3).listen(8083);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment