learning express step(八)
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(八)的更多相关文章
- 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(七)
Route handlers enable you to define multiple routes for a path. The example below defines two routes ...
- learning express step(六)
code: use application middleware var express = require('express'); var app = express(); app.use(func ...
随机推荐
- 关于scanf()读取与返回值和回车键的问题
今天老师检查的时候说如果一个链表为空(简单的说就是while(scanf())一开始没输入数字就按回车的话会进入死循环)的情况, 我当时有点懵,因为文档里强调为空的情况.还好老师叫我自己现场实现一下, ...
- c# asp.net 实现分页(pager)功能
分页PagerHelper辅助类 using System;using System.Web; public class PagerHelper { #region 获取分页的Html代码 /// & ...
- sql注入测试(4)--如何防止该类缺陷发生
检查用户输入的合法性,确信输入的内容只包含合法的数据,数据检查应当在客户端和服务器端都执行之所以要执行服务器端验证,是为了弥补客户端验证机制脆弱的安全性.在客户端,攻击者完全有可能获得网页的源代码,修 ...
- (十六)客户端验证与struts2中的服务器端验证
一.客户端验证: 即用javaScript来验证. <%@ page language="java" contentType="text/html; charset ...
- python 练习:函数1
习题: 定义一个方法 func,该func可以引入任意多的整型参数,结果返回其中最大与最小的值. def func(**args): return max(args),min(args) 定义一个方法 ...
- 移动端 H5 上拉刷新,下拉加载
http://www.mescroll.com/api.html#options 这里有几个重要的设置 1.down 下不启用下拉刷新是因为再手机端有默认的下拉刷新,会冲突,待解决 2.up 中的 a ...
- ubuntu14.04
14.10显卡驱动有问题 1.恢复启动引导菜单:启动盘 -> 运行到分区之前,不要分区 -> shift+f10 进入dos -> bootsec /fixmbr ->关闭重启 ...
- gitea configure
gitea configure app.ini APP_NAME = Gitea: Git with a cup of tea RUN_USER = LSGX RUN_MODE = prod [oau ...
- Python练习_函数进阶_day10
1. 1.作业 1,写函数,接收n个数字,求这些参数数字的和.(动态传参) 2,读代码,回答:代码中,打印出来的值a,b,c分别是什么?为什么? a=10 b=20 def test5(a,b): p ...
- Hadoop错误:PipeMapRed.waitOutputThreads(): subprocess failed with code 1
有一种原因是python文件中有语法或逻辑错误