Last active
August 29, 2015 14:16
-
-
Save rkamradt/23cad5920f3783ac7040 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
// REST methods: | |
// GET returns a list with optional filters | |
// GET :id returns a single document | |
// POST :id {doc} updates a single document | |
// PUT {doc} adds a single document | |
// DELETE :id deletes a single document | |
module.exports = function() { | |
return function(req, res, next) { | |
console.log("routing url " + req.url); | |
if(req.method === 'GET') { | |
res.status(200).send('GET processing on model ' + req.url + '\n'); | |
} else if(req.method === 'POST') { | |
res.status(200).send('POST processing on model ' + req.url + '\n'); | |
} else if(req.method === 'PUT') { | |
res.status(200).send('PUT processing on model ' + req.url + '\n'); | |
} else if(req.method === 'DELETE') { | |
res.status(200).send('DELETE processing on model ' + req.url + '\n'); | |
} else { | |
res.status(500).send('unrecognized verb'); | |
} | |
res.end(); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment