Last active
December 19, 2015 13:19
-
-
Save lxe/5961614 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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