express添加拦截器
var express = require('express')
, routes = require('./routes')
, http = require('http')
, path = require('path');
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 3000);
// 第1个filter
app.use(function (req, res, next) {
console.log(req.headers.host);
next();
});
// 第2个filter
app.use(function (req, res, next) {
console.log(req.headers.host);
next();
});
// 第3个filter
app.use(function (req, res, next) {
console.log(req.headers.host);
next();
});
});
, routes = require('./routes')
, http = require('http')
, path = require('path');
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 3000);
// 第1个filter
app.use(function (req, res, next) {
console.log(req.headers.host);
next();
});
// 第2个filter
app.use(function (req, res, next) {
console.log(req.headers.host);
next();
});
// 第3个filter
app.use(function (req, res, next) {
console.log(req.headers.host);
next();
});
});
坚持,坚持,再坚持。