山
Koa 的简单路由
安装
npm install mountain-js
用法
const route = require("mountain-js");
例子
let app = koa();
app.use(route("GET", "/posts", function *(next) {
this.body = "got posts!";
}));
app.listen();
允许所有方法的路由。
app.use(route("/posts", function *(next) {
this.body = "always got posts!";
}));
参数化的 URL。
app.use(route("GET", "/posts/:id", function *(next) {
this.body = "got post #" + this.par
1