Skip to content

Instantly share code, notes, and snippets.

@yeyuguo
Created January 29, 2018 14:12
Show Gist options
  • Save yeyuguo/ff023fcda333d0307acc5a93366430f0 to your computer and use it in GitHub Desktop.
Save yeyuguo/ff023fcda333d0307acc5a93366430f0 to your computer and use it in GitHub Desktop.
调试 express 的代码
/**调试 express 源码的调试代码 */
var express = require('express')
// express 初始化
var app = express()
// 使用 中间件
app.use('/users', function(req, res, next) {
// req.path will be the req.url with the /users prefix stripped
console.log('%s', req.path);
next();
});
// 使用 路由
app.get('/', function (req, res) {
res.send('Hello World')
})
// 使用 事件监听
app.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment