Skip to content

Instantly share code, notes, and snippets.

@AdrianRossouw
Created February 14, 2011 19:41
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 AdrianRossouw/826409 to your computer and use it in GitHub Desktop.
Save AdrianRossouw/826409 to your computer and use it in GitHub Desktop.
require.paths.unshift(__dirname + '/modules', __dirname + '/lib/node', __dirname);
var connect = require('connect'),
express = require('express'),
sys = require('sys');
var app = new express.Server();
// expectation : will be run after the more general app.all().
app.get('/foo', function(req, res, next) {
console.log('foo');
res.send('foo');
// purposefully not calling next()
});
// expectation: will be run before app.get().
app.all('/foo', function(req, res, next) {
// allow us to populate things in the req/res for all pages that match the route.
console.log('here');
next();
});
app.listen(8888);
// results : with app.all first in code, expected results occur.
// with app.get first in code, only app.get is run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment