Skip to content

Instantly share code, notes, and snippets.

@PradalCyril
Created January 7, 2019 15:58
Show Gist options
  • Save PradalCyril/7fa97f148a0841eabce9fb7908b7daa6 to your computer and use it in GitHub Desktop.
Save PradalCyril/7fa97f148a0841eabce9fb7908b7daa6 to your computer and use it in GitHub Desktop.
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res, next) {
res.send('Hey ! It\'s a GET');
});
/* GET user with ID. */
router.get('/:id(\\d+)', function(req, res, next) {
res.send('Hey ! It\'s a GET with ID ' + req.params.id);
});
router.put('/put/:name', function(req, res, next) {
res.send('Hey ! It\'s a PUT with name ' + req.params.name);
});
router.delete('/delete/:name(\\d+)', function(req, res, next) {
res.send('Hey ! It\'s a DELETE with name ' + req.params.name);
});
/* POST user creation. */
router.post('/', function(req, res, next) {
res.send('Hey ! It\'s a POST');
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment