Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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