-
Notifications
You must be signed in to change notification settings - Fork 0
/
dishRouter1.js
36 lines (26 loc) · 887 Bytes
/
dishRouter1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const express = require('express');
const bodyParser = require('body-parser');
const morgan=require('morgan');
const dishRouter1 = express.Router();
dishRouter1.use(bodyParser.json());
dishRouter1.route('/')
.all((req,res,next)=>{
res.statusCode=200;
res.setHeader('content-Type','text/plain');
next();
})
.get((req,res,next)=> {
res.end('will send details of dishes: '+req.params.dishId+'to you');
})
.post((req,res,next)=>{
res.statusCode=403;
res.end('post operation not supported on /dishes/'+req.params.dishId);
})
.put((req,res,next)=>{
res.write('updaing the dish'+req.params.dishId+'\n');
res.end('will update the dish: '+req.body.name +'with details: '+req.body.description);
})
.delete((req,res,next)=> {
res.end('deleting the dishe!'+req.params.dishId);
});
//module.exports = dishRouter1;