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

const express = require('express');
const app = express(); app.get('/user/:id', function (req, res, next) {
if (req.params.id === '') next('route')
else next()
}, function (req, res, next) {
res.send('regular');
}
); app.get('/user/:id', function (req, res, next) {
res.send('special');
}); app.listen();

web result:

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(七)

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

  9. learning express step(六)

    code: use application middleware var express = require('express'); var app = express(); app.use(func ...

随机推荐

  1. nginx 设置开机启动

    设置nginx开机启动chkconfig --add /etc/init.d/nginx chkconfig nginx on

  2. Nginx学习笔记(一):Nginx 进程模型 / 事件处理模型

    Nginx 进程模型 ​​​​ 多进程模型 进程间相互独立,无需加锁,且互不影响: 一个进程退出了不影响其他的进程运行,降低风险: 当请求到来,多个 worker 通过竞争 accrpt_mutex ...

  3. Message高级特性

    一.延迟和定时消息投递 1 xml中配置schedulerSupport属性为true 2 每小时都会发生消息被投递10次,延迟1秒开始,每次间隔1秒: TextMessage message = s ...

  4. Word文档转PDF方法探索

    最近的项目中需要将Word转换为PDF文件,找了很多方法和组件,最后找到了一些方法,和大家分享. 一.使用微软官方自带转换方法 好处是写法方便,官方支持,缺点是需要在服务器上安装office,而且要配 ...

  5. 把zTree前的展开收起图标改为三角形,且只有在点击三角形图标时才展开子节点解决方案

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta ht ...

  6. 如何判断是否是ssd硬盘?win10查看固态硬盘的方法

    转自:http://www.w10zj.com/Win10xy/Win10yh_7732.html 如何判断是否是ssd硬盘?在win10操作系统中我们该如何查看当前主机中安装的是固态硬盘还是机械硬盘 ...

  7. gcc和g++编译器

    .c文件,gcc当做c语言处理 .cpp文件,gcc和g++当做c++处理 .c文件和.cpp文件编译时,都是使用的gcc编译器 .cpp使用gcc链接,需要加入-lstdc++选项 举例 #incl ...

  8. 【leetcode】566. Reshape the Matrix

    原题 In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a ne ...

  9. HTML5 canvas 在线涂鸦

    插件地址 http://bencentra.github.io/jq-signature/ 采用技术 jq-signature.min.js Developed using jQuery 2.1.4. ...

  10. Win10系统更新提示错误0xc1900403的解决方法

    Win10系统自从发布上线以来,一直有不断地进行更新,而每次更新也给我们用户带来了大大小小不同的惊喜.但是近来一些用户反应说Win10系统更新一直失败,并出现0xc1900403的错误代码提示. 对于 ...