Skip to content

Instantly share code, notes, and snippets.

@lxe
Last active December 19, 2015 13:19
Show Gist options
  • Save lxe/5961614 to your computer and use it in GitHub Desktop.
Save lxe/5961614 to your computer and use it in GitHub Desktop.
var express = require('express')
, app = express()
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
// Freeze the route to /foo/static
app.get('/foo/static', function(req, res, next) {
if (!req.accepts('html')) {
/* do the thing */
res.send('A thing');
} else {
/* fall through */
next();
}
});
// Everything else other than /foo/static is treated as a parameter
app.get('/foo/:id', function(req, res, next) {
res.send(req.param('id'));
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment