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 ...
随机推荐
- hdu 6165
虽然题解上说缩点然后判断入度就可以了,然后比赛的时候瞎暴力过了. #include <iostream> #include <cstring> #include <str ...
- IDEA如何本机调试springboot应用打的jar包
背景: 我用命名行 执行 java -jar ***.jar发现 springboot启动时抛出错误,因此想debug进去看看究竟为什么出错. 1 在命令行执行 java -jar -Xdebug ...
- JDBC 学习复习8 C3P0数据源使用
C3P0是一个开源的JDBC连接池,它实现了数据源和JNDI绑定,支持JDBC3规范和JDBC2的标准扩展.目前使用它的开源项目有Hibernate,Spring等. c3p0与dbcp区别 dbcp ...
- HTTP协议 学习
HTTP是hypertext transfer protocol(超文本传输协议)的简写,它是TCP/IP协议的一个应用层协议,用于定义WEB浏览器与WEB服务器之间交换数据的过程.客户端连上web服 ...
- C#使用Selenium网页自动化
工作中很多时候经常需要网抓数据或者把数据填写到网站上,使用Selenium将其自动化是一种不错的选择.Selenium其实是一个用于Web应用程序测试的工具,测试你的应用程序看是否能够很好地工作在不同 ...
- JS基础_函数作用域
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- JQuery攻略读书笔记---第2章 数组
2 数组2.8 创建对象数组循环数组2.9 数组排序 2 数组 2.8 创建对象数组 //数组化对象 var student =[ { "role":101, "na ...
- kong命令(三)route
介绍 route 是一套匹配客户端请求的规则.每个route都会匹配一个service,每个service可定关联多个route. 可以说service:route=1:n.一对多的关系.每个匹配到r ...
- Navicat MySql 连不上 本地开发环境 MySQL8.0
原因: 新版mysql数据库的加密方式改变,进而导致Navicat连接输入的密码不能与安装时输入的密码匹配,那如何解决这个问题呢?很简单,只需要一句代码的事儿~ 1.打开MySQL 8.0 Com ...
- restTemplate源码解析(二)restTemplate的核心逻辑
所有文章 https://www.cnblogs.com/lay2017/p/11740855.html 正文 上一篇文章中,我们构造了一个RestTemplate的Bean实例对象.本文将主要了解一 ...