import { Router } from "https://deno.land/x/oak/mod.ts";
const router = new Router();
import { toRouter } from "../Service/index.js";
router.get("/", (context) => {
context.response.body = "Hello 路飞!!";
});
router
.get("/1.1/classes/garden", toRouter)
.post("/1.1/classes/garden", toRouter)
.get("/1.1/classes/garden/:id", toRouter)
.put("/1.1/classes/garden/:id", toRouter)
.delete("/1.1/classes/garden/:id", toRouter);
以上deno中间件有没有类似node的express用法:
app.use("/1.1/classes/garden", require("./api/garden"));
const router = express.Router();
router.get("/",async (req, res)=>{} );
router.get("/:id",async (req, res)=>{} );
router.post("/",async (req, res)=>{} );等等路径只需要写一次,改动也方便