const express = require('express');const app = express();
app.use((req, res, next) => {console.log('请求走了use中间件');next();
})
app.use('/request', (req, res, next) => {console.log('请求走了use中间件/hh')next()
})
app.get('/list', (req, res) => {//send 响应内容的累心//http 状态码req.send = ('/list');})
app.get('/request', (req, res, next) => {//send 响应内容的累心//http 状态码req.name = '张三';next();
})
app.get('/request', (req, res) => {//send 响应内容的累心//http 状态码res.send(req.name);
})
app.listen(3000);
console.log('服务器启动成功');
运行结果