Last active
August 29, 2015 14:04
-
-
Save vincenting/d0337252bb8912467090 to your computer and use it in GitHub Desktop.
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
| var express = require('express'); | |
| var app = express(); | |
| var router = express.Router(); | |
| router.get('/', function (req, res) { | |
| res.send('hello world'); | |
| }); | |
| router.get('/reset', function (req, res) { | |
| var router_stack = router.stack.concat([]); | |
| router.stack.length = 0; | |
| router_stack.forEach(function (item) { | |
| if (item.route.path !== '/') { | |
| router.stack.push(item); | |
| } | |
| }); | |
| res.send('ok'); | |
| }); | |
| process.on('SIGTERM', function() { | |
| console.log('Controller will be reload'); | |
| }); | |
| app.use(router); | |
| app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问一个小白问题,router.stack 明明是数组,为什么还要.concat([])呢?