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. PAT(B) 1021 个位数统计(Java)

    题目链接:1021 个位数统计 (15 point(s)) 代码 /** * Score 15 * Run Time 93ms * @author wowpH * @version 1.0 */ im ...

  2. hdu 6216 A Cubic number and A Cubic Number

    题意:给定一个素数,判定它是不是两个立方数之差. 题解:对于a^3+b^3=(a-b)(a^2-a*b+b^2),而一个素数的因子只有1和其本身,在加上(a^2-a*b+b^2)一定是大于1的,所以只 ...

  3. IntelliJ IDEA 最新版 2019.2.4 激活 (持续更新)(含windows和Mac)

    IntelliJ IDEA 最新版 2019.2.4 激活 最新版激活包下载地址: 百度网盘 提取码: i28c 转载: Neo Peng Jetbrains系列产品 激活方式 同下述方式相同,只需要 ...

  4. (二十二)SpringBoot之使用mybatis generator自动生成bean、mapper、mapper xml

    一.下载mybatis generator插件 二.生成generatorConfig.xml new一个generatorConfig.xml 三.修改generatorConfig.xml 里面的 ...

  5. C#基础--AbStract与Interface

         Interface: 接口方法不能用public abstract等修饰.接口内不能有字段变量,构造函数. 接口内可以定义属性,如string color{get;set;}这种. 实现接口 ...

  6. angular select 的第一行option 空白问题

    记录一下这个问题的解决方案 <select class="form-control" ng-init="vm.columnId = vm.columnList[0] ...

  7. XXX银行人事管理系统-数据库设计

    1. 用户.权限.角色关系用户基本信息 userinfo [人员表]权限表actions[权限表]员工类型表usertype [管理组表]权限映射表actionmapping [权限映射表]权限分栏表 ...

  8. Linux学习笔记:split切分文件并按规律命名及添加拓展名

    基础知识 功能:使用 shell 的 split 可以将一个大文件分割成很多个小文件,有时文件太大处理起来不方便就需要使用到了. 在默认情况下将按照每1000行切割成一个小文件. 语法: split ...

  9. log:日志处理模块

    为了更好的跟踪程序,我们通常都会使用日志,当然在golang中也提供了相应的模块. 基本使用 可以直接通过log来调用格式化输出的方法. package main import "log&q ...

  10. (转载)关于FLASH寿命的读写方法

    NOR(或非)和NAND(与非)是市场上两种主要的Flash闪存,sNORFLASH 和CPU之间不需要其他电路控制,NOR flash可以芯片内执行程序,而NAND FLASH 和CPU 的接口必须 ...