Skip to content

Instantly share code, notes, and snippets.

@EvanHahn
Created February 17, 2014 22:54
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 EvanHahn/9060896 to your computer and use it in GitHub Desktop.
Save EvanHahn/9060896 to your computer and use it in GitHub Desktop.
var express = require('express');
var app = express();
app.all('*', function(req, res, next) {
var youAreAllowed = Math.random() < 0.5; // example
if (youAreAllowed)
next();
else
res.send(403);
});
// By the way:
// You might want the above thing to be middleware if it handles EVERYTHING.
// Looks very similar, but the first line looks like this:
// app.use(function(req, res, next) {
// ..
app.get('/', function(req, res) {
res.send('hello world!');
});
app.listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment