Created
February 17, 2014 22:54
-
-
Save EvanHahn/9060896 to your computer and use it in GitHub Desktop.
This file contains hidden or 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'); | |
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