Skip to content

Instantly share code, notes, and snippets.

@ShakataGaNai
Created July 28, 2013 23:40
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 ShakataGaNai/6100743 to your computer and use it in GitHub Desktop.
Save ShakataGaNai/6100743 to your computer and use it in GitHub Desktop.
var express = require("express");
var app = express();
// http://localhost:9001/users/1
app.get('/users/:id', function(req, res, next){
var id = req.params.id;
if (checkPermission(id)) {
res.send("private");
} else {
next();
}
});
// http://localhost:9001/users/2
app.get('/users/:id', function(req, res){
res.send("public");
});
app.listen(9001);
function checkPermission(id){
if(id == 1){
return true;
}else{
return false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment