koajs / discussions

KoaJS Discussions
2 stars 2 forks source link

how to reg two part to the same file #35

Open gclinux opened 7 years ago

gclinux commented 7 years ago

test1 router.use('/test', require('./test').routes(), require('./test').allowedMethods()); /test -->ok /test2-->404

test2: router.use(['/test','test2'], require('./test').routes(), require('./test').allowedMethods()); /test -->404 /test2-->404

test3

router.use('/test', require('./test').routes(), require('./test').allowedMethods());
router.use('/test2', require('./test').routes(), require('./test').allowedMethods());

/test->404 /test2-->404

test.js:

var router = require('koa-router')();
router.get('/', async function (ctx, next) {
ctx.body='ok'
})
module.exports = router;

how to make both the /test and /test2 can be accesss