import ServeRouter from "https://esm.sh/serve-router@latest";
const app = ServeRouter();
app.get("/", () => new Response("Hello, world!"));
app.get("/headers", (req: Request) => Response.json(Object.fromEntries(req.headers.entries())));
app.get("/user/:name", (_req, { params }) => {
return new Response(`Hello, ${params.name}`);
});
app.post("/post", async (req) => {
const json = await req.json();
return Response.json(json);
});
app.route("/api")
.get("", () => new Response("api"))
.get("/one", () => new Response("one"))
.get("/two", () => new Response("two"));
export const serve_router = app.fetch