learning express step(六)
code: use application middleware
var express = require('express');
var app = express();
app.use(function (req, res, next) {
console.log('Time', Date.now());
next()
});
app.use('/user/:id', function (req, res, next) {
console.log('Request Type:', req.method);
next();
},function (req, res, next) {
console.log('Request URL', req.originalUrl);
next();
});
app.get('/user/:id', function(req, res){
res.send("USER");
});
app.listen();
result:
C:\Users\admin\WebstormProjects\learning-express-step6>node learning-express-step6.js
Time
Request Type: GET
Request URL /user/id=
Time
Request Type: GET
Request URL /user/id=
web result: pass id field

learning express step(六)的更多相关文章
- learning express step(十四)
learning express error handle code: const express = require('express'); const app = express(); const ...
- learning express step(十三)
learning express error handle code: const express = require('express'); const app = express(); app.g ...
- learning express step(十二)
learning express view engine function const express = require('express'); const app = express(); app ...
- learning express step(十一)
learning express.Router() code: const express = require('express'); const app = express(); var route ...
- learning express step(五)
learning express middleware var express = require('express'); var app = express(); var myLogger = ...
- learning express step(四)
learning express route function const express = require('express'); const app = express(); app.get(' ...
- learning express step(九)
router-level middleware works in the same way as application-level middleware, except it is bound to ...
- learning express step(八)
To skip the rest of the middleware functions from a router middleware stack, call next('route') to p ...
- learning express step(七)
Route handlers enable you to define multiple routes for a path. The example below defines two routes ...
随机推荐
- go 函数闭包
Go 函数可以是闭包的.闭包是一个函数值,它来自函数体的外部的变量引用. 函数可以对这个引用值进行访问和赋值:换句话说这个函数被“绑定”在这个变量上. 例如,函数 adder 返回一个闭包.每个闭包都 ...
- apache - storm - Setting Up a Development Environment
Installing a Storm release locally If you want to be able to submit topologies to a remote cluster f ...
- chrome 调试 ios h5
1,安装itunes, 否则无法识别iphone设备 2,开启调试模式 ,打开 iPhone 依次进入 设置 > Safari > 高级 > Web 检查 > 启用 3,下载 ...
- 【规律】Cunning Friends
Cunning Friends 题目描述 Anthony and his friends Ben and Chris decided to play a game. They have N piles ...
- redis键的排序操作
命令名称:sort 语法:sort key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ ...
- ASP.NET WEB应用程序(.network4.5)MVC Razor视图引擎2
https://www.bbsmax.com/A/gAJG67OXzZ/ 在MVC3.0版本的时候,微软终于引入了第二种模板引擎:Razor.在这之前,我们一直在使用WebForm时代沿留下来的ASP ...
- 通过数组的某一个属性值进行排序(如id)
let arr = [ {id: 1, name: 'aaa'}, {id: 4, name: 'ddd'}, {id: 2, name: 'bbb'}, {id: 3, name: 'ccc'} ] ...
- Flutter自定义绘制(1)- 绘制基础
CustomPainter Flutter 中实现绘制的主要是CustomPainter类. 我们一般继承这个类,来使用它: class MyPainter extends CustomPainter ...
- CSS属性margin、padding的区别
原始状态 不设置margin和padding的状态 margin 设置外边距之后的状态 padding 设置内边距之后的状态 ,注意是撑开,外框高宽由300px变成450px. 说明:本文为原创作品, ...
- Axure工作区间
Axure的工作环境可进行可视化拖拉操作,可轻松快速的创建带有注释的线框图.无需编程就可以在线框图中定义简单链接和高级交互.Axure可一体化生成线框图.HTML交互原型.规格说明Word文档.以下是 ...