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(六)的更多相关文章

  1. learning express step(十四)

    learning express error handle code: const express = require('express'); const app = express(); const ...

  2. learning express step(十三)

    learning express error handle code: const express = require('express'); const app = express(); app.g ...

  3. learning express step(十二)

    learning express view engine function const express = require('express'); const app = express(); app ...

  4. learning express step(十一)

    learning express.Router() code: const express = require('express'); const app = express(); var route ...

  5. learning express step(五)

    learning  express  middleware var express = require('express'); var app = express(); var myLogger = ...

  6. learning express step(四)

    learning express route function const express = require('express'); const app = express(); app.get(' ...

  7. learning express step(九)

    router-level middleware works in the same way as application-level middleware, except it is bound to ...

  8. learning express step(八)

    To skip the rest of the middleware functions from a router middleware stack, call next('route') to p ...

  9. learning express step(七)

    Route handlers enable you to define multiple routes for a path. The example below defines two routes ...

随机推荐

  1. (三)Struts之Action类基础(一)

    一.Action的类型 A.使用普通的类 必须有public的execute且返回值为String的方法. ActionType.java package com; public class Acti ...

  2. win10 amd显卡开机黑屏很久

    转载自:https://jingyan.baidu.com/article/3c48dd34844e0ce10ae35865.html 升级win10后,使用a卡的小伙伴应该会大为恼火,开机竟然需要黑 ...

  3. Windows 10 下 Linux 子系统的安装和使用

    介绍 适用于 Windows 的 Linux 子系统(英语:Windows Subsystem for Linux,简称 WSL)是一个为在 Windows 10 和 Windows Server 2 ...

  4. 动手实现CNN卷积神经网络

    数据集采用的是手写数据集(http://yann.lecun.com/exdb/mnist/): 本文构建的CNN网络图如下: 像素点:28*28 = 784,55000张手写数字图片. # -*- ...

  5. 结合python实现的netcat与python实现的tcp代理,建立一个流量隧道

    在proxy中 python2 proxy.py 127.0.0.1 3334 192.158.1.111 80 true 作为服务器在本地3334端口进行监听, 作为客户端连接远程web服务器192 ...

  6. css滑动门技术

    滑动门的核心技术: 为了使各种特殊形状的背景能够自适应元素中文本内容的多少,以使自由拉伸滑动 利用css精灵(主要是背景位置)和盒子padding撑开宽度,以便适应不同字数的导航栏 一般经典布局 &l ...

  7. leetcode-29.两数相除(不用乘除法和mod)

    如题,不用乘除法和mod实现两数相除. 这里引用一位clever boy 的解法. class Solution { public: int divide(int dividend, int divi ...

  8. gitlab中的几个常用界面(runner管理、gitlab-ci.yml管理、runner token管理、新建用户、拉用户入工程、拉用户入组、复制工程导入组)

    目录: 1.runner管理 2.gitlab-ci.yml管理 3.runner token管理 4.新建用户 5.拉用户入工程 6.拉用户入组 7.复制工程导入组 1.runners界面 http ...

  9. 【Distributed】分布式锁

    一.概述 1.1 分布式解决的核心思路 1.2 分布式锁一般有三种实现方式 二.基于Redis的分布式锁 2.1 使用常用命令 2.2 实现思路 2.3 核心代码 Maven依赖信息 LockRedi ...

  10. python中yield的用法详解-转载

    原文链接:https://blog.csdn.net/mieleizhi0522/article/details/82142856 ,今天在写python爬虫的时候,循环的时候用到了yield,于是搜 ...