koa-router的基本用法
const Koa = require('koa');
const KoaRouter = require('koa-router');
const app = new Koa();
const router = new KoaRouter();
router.get('/', (ctx, next) => {
ctx.body = {key: 'index'}
});
router.post('/users', (ctx, next) => {
ctx.body = {key: 'post'}
});
router.put('/users', (ctx, next) => {
ctx.body = {key: 'put'}
});
router.delete('/user', (ctx, next) => {
ctx.body = {key: 'delete'}
});