Created
January 29, 2018 14:12
-
-
Save yeyuguo/ff023fcda333d0307acc5a93366430f0 to your computer and use it in GitHub Desktop.
调试 express 的代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /**调试 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