import { forMethod } from "https://deno.land/x/reno@v2.0.75/reno/mod.ts";
Takes mappings of HTTP methods and route handler functions, and returns a higher-order route handler that will forward requests to the correct handler by their method. Any requests whose method does not have an associated handler will result in a HTTP 405:
const get = () => new Response("You performed a HTTP GET!");
const post = () => new Response("You performed a HTTP POST!");
const routes = createRouteMap([
["/endpoint", forMethod([
["GET", get],
["POST", post],
])],
]);
export const methodsRouter = createRouter(routes);