Powered by
functional composition and
the
URL Pattern API,
composium
has become the most flexible routing framework in the world. Through
its composability it can serve perfectly as a generic, abstract and
minimal layer for your own back-end framework.
The best way to learn and test the URL Pattern API is Zaubrik's free URL Pattern User Interface.
deno doc https://deno.land/x/composium/mod.ts
import { Context, createDefaultHandler, createGetRoute } from "./mod.ts";
function welcome<C extends Context>(ctx: C) {
const name = ctx.result.pathname.groups.name || "nobody";
ctx.response = new Response(`Welcome, ${name}!`);
return ctx;
}
const route = createGetRoute({ pathname: "/{:name}?" })(welcome);
const handler = createDefaultHandler(route);
Deno.serve(handler);
// curl http://localhost:8080/Joe
// Welcome, Joe!
Feel free to ask questions and start discussions in our discord server.