Guest User

Untitled

a guest
Apr 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. var express = require('express');
  2. var router = express.Router();
  3.  
  4. /* GET users listing. */
  5. router.get('/', function(req, res, next) {
  6. res.send('respond with a resource');
  7. });
  8.  
  9. /* GET user with id. */
  10.  
  11. router.get('/:id(\\d+)', function(req, res, next) {
  12. res.send('hey ! it\'s a GET with ID ' + req.params.id)
  13. })
  14.  
  15. /* POST user creation. */
  16.  
  17. router.post('/', function(req, res, next){
  18. res.send('hey ! it\'s a post')
  19. })
  20.  
  21. /* PUT user name. */
  22.  
  23. router.put('/:prenom', function(req, res, next){
  24. res.send('hey ! my name is ' + req.params.prenom)
  25. })
  26.  
  27. /* DELETE user ID. */
  28.  
  29. router.delete('/:id(\\d+)', function(req, res, next) {
  30. res.send('hey ! it\'s a DELETE ID ' + req.params.id)
  31. })
  32.  
  33.  
  34. module.exports = router;
Add Comment
Please, Sign In to add comment