nodejs 里面的next()这个函数调用的作用是什么呢?

var express = require('express');
var app = express();
var myLogger = function(req, res, next){
console.log("Logger--");
next();
}
app.use(myLogger); app.get('/', function(req, res, next){
// console.log(req);
console.log('/');
var buffer = new Buffer(6);
buffer.fill('春天');
console.log(buffer.toString());
next(); res.send({msg: 'hello,world!'});
}, function(req, res, next){
console.log('next');
next();
}, function(){
console.log('next 2');
}) app.get('/user', function(req, res){
console.log('/user');
res.send('/user');
});
var server = app.listen(8081, '0.0.0.0', function(){
var host = server.address().address;
var port = server.address().port;
console.log('http://%s:%s', host, port);
});

  

参考: https://stackoverflow.com/questions/5384526/javascript-node-js-next

express next function的更多相关文章

  1. express全局安装后无法通过require使用

    今天入门了一下express,首先安装依赖. npm install express -g; npm install body-parser -g; npm install cookie-parser ...

  2. 2.实现Express中间件

    Express提供的大部分功能都是通过中间件函数完成,这些中间件函数在Node.js收到 请求的时点 和 发送响应的时点 执行 connect模块提供了中间件框剪 方便在全局或路径级别或为单个路由插入 ...

  3. [Express] Level 2: Middleware -- 2

    Logging Middleware Help finish the following middleware code in the logger.js file: On the response  ...

  4. Express异步进化史

    1.导言 在 Javascript 的世界里,异步(由于JavaScript的单线程运行,所以JavaScript中的异步是可以阻塞的)无处不在. Express 是 node 环境中非常流行的Web ...

  5. 理解express中的中间件

    express是轻量灵活的node.js Web应用框架”.它可以帮助你快速搭建web应用.express是一个自身功能极简,完全是由**路由**和**中间件**构成的一个web开发框架,本质上说,一 ...

  6. nodejs express 学习

    nodejs的大名好多人应该是听过的,而作为nodejs web 开发的框架express 大家也应该比较熟悉. 记录一下关于express API 的文档: express() 创建express ...

  7. Node.js之Express四

    Express提供的大部分功能是通过中间件函数完成的,这些中间件函数在Node.js收到请求的时点和发送响应的时点之间执行.Express的Connect模块提供了中间件框架,可以方便的在全局或路径级 ...

  8. Node.js之Express一

    前面也了解了HTTP模块,但它并不支持session.cookie等.Express是对HTTP模块的封装,同时也支持session这些,使用起来也更好用.Express更有点像IIS服务器.它也是属 ...

  9. Express详解

    express() 创建一个express应用程序 var express = require('express'); var app = express(); app.get('/', functi ...

随机推荐

  1. Spring_之注解事务 @Transactional

    spring 事务注解 默认遇到throw new RuntimeException("...");会回滚需要捕获的throw new Exception("...&qu ...

  2. [原创] 浅谈ETL系统架构如何测试?

    [原创] 浅谈ETL系统架构如何测试? 来新公司已入职3个月时间,由于公司所处于互联网基金行业,基金天然固有特点,基金业务复杂,基金数据信息众多,基金经理众多等,所以大家可想一下,基民要想赚钱真不容易 ...

  3. TCPIP网络协议层对应的RFC文档

    原文地址:TCPIP网络协议层对应的RFC文档作者:西木 RFC - Request For Comments 请求注解 TCP/IP层 网络协议 RFC文档 Physical Layer Data ...

  4. WinForm基于插件开发实现多项配置存储

    一.课程介绍和实例在线演示 明人不说暗话,跟着阿笨一起玩WinForm.本次分享课程属于<C#高级编程实战技能开发宝典课程系列>中的一部分,阿笨后续会计划将实际项目中的一些比较实用的关于C ...

  5. Xamarin.Android,Xamarin.iOS, Linking

    Xamarin.Android applications use a linker in order to reduce the size of the application. The linker ...

  6. canvas使用1

    画直线: ? 1 2 3 4 5 6 7 8 9 10 11 var c = document.getElementById("myCanvas"); //不要忘写document ...

  7. Nginx rewrite URL examples with and without redirect address

    原文地址: http://www.claudiokuenzler.com/blog/436/nginx-rewrite-url-examples-with-without-redirect-addre ...

  8. Linux init 0-6 启动级别

    原文地址:http://blog.sina.com.cn/s/blog_5f8e8d9801010wlr.html 原文地址:[转]Linux init 0-6 启动级别作者:流水清风 init 0- ...

  9. NSURLRequest with UserAgent

    关于iOS上的http请求还在不断学习,从早先的时候发现原来iOS的http请求可以自动保存cookie到后来的,发现ASIHttpRequest会有User-Agent,到现在发现竟然NSURLRe ...

  10. View Programming Guide for iOS_读书笔记[正在更新……]

    原文:View Programming Guide for iOS 1 Introduction 先熟悉一下基本概念. Window Windows do not have any visible c ...