Skip to main content
Module

x/abc/docs/router.md

A better Deno framework to create web application.
Latest
File

Router

The router module based on zhmushan/router.

We will always match according to the rules of Static > Param > Any. For static routes, we always match strictly equal strings.

Pattern: /* ,/user/:name, /user/zhmushan

path route
/zhmushan /*
/users/zhmushan /*
/user/zhmushan /user/zhmushan
/user/other /user/:name

Basic route

import { Application } from "https://deno.land/x/abc@v1.3.3/mod.ts";

const app = new Application();

app.get("/user/:name", (c) => {
  const { name } = c.params;
  return `Hello ${name}!`;
});

Group route

// user_group.ts
import type { Group } from "https://deno.land/x/abc@v1.3.3/mod.ts";

export default function (g: Group) {
  g.get("/:name", (c) => {
    const { name } = c.params;
    return `Hello ${name}!`;
  });
}
import { Application } from "https://deno.land/x/abc@v1.3.3/mod.ts";
import userGroup from "./user_group.ts";

const app = new Application();

userGroup(app.group("user"));