express4.x中的链式路由句柄
1 var express = require("express"); 2 var router = express(); 3 4 router.get('/', function (req, res) { 5 res.render('articles', {titles: '文章页', content: '这是文章页的内容,method==' + req.method}); 6 }) 7 .post('/', function (req, res) { 8 res.json({msg: "添加文章成功"}) 9 }) 10 .put('/', function (req, res) { 11 if (req.body.id) { 12 res.json({msg: "文章修改成功"}) 13 } 14 }); 15 16 module.exports = router;