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();
  });
});
posted @ 2015-11-29 17:23  业精于勤而荒于嬉  阅读(664)  评论(0编辑  收藏  举报