我想跟koa2中路由分割一样。
访问这个:localhost:8080/hall/get
import { Application } from “https://deno.land/x/oak/mod.ts”;
import { Router } from “https://deno.land/x/oak/mod.ts”;
const app = new Application();
const hall = new Router();
const getProducts = ({ response }: { response: any }) => {
response.body = {
success: true,
data: 'getProducts',
};
};
hall.get("/get", getProducts);
const router = new Router();
router.use(’/hall’,hall.routes(),hall.allowedMethods());
app.use(router.routes());
app.use(router.allowedMethods());
await app.listen({ port: 8080 });