在Express中间件中,应该采用3个参数:请求,响应,下一步。 但是,在我从书中复制的代码中的第二个中间件,但只使用请求,响应。这里的原因是什么?接下来是可选的?
var express = require("express");
var http = require("http");
var app = express();
app.use(function(request, response, next) {
console.log("In comes a " + request.method + " to " + request.url);
next();
});
app.use(function(request, response) {
response.writeHead(200, { "Content-Type": "text/plain" });
response.end("Hello, world!");
});
http.createServer(app).listen(3000);