Module

x/fresh/src/server/deps.ts>rutt.router

The next-gen web framework.
Extremely Popular
Go to Latest
function rutt.router
import { rutt } from "https://dotland.deno.dev/x/fresh@1.1.5/src/server/deps.ts";
const { router } = rutt;

A simple and tiny router for deno. This function provides a way of constructing a HTTP request handler for the provided {@link routes} and any provided RouterOptions.

Examples

Example 1

import { serve } from "https://deno.land/std/http/server.ts";
import { router } from "https://deno.land/x/rutt/mod.ts";

await serve(
  router({
    "/": (_req) => new Response("Hello world!", { status: 200 }),
  }),
);

Type Parameters

optional
T = unknown

Parameters

routes: Routes<T> | InternalRoutes<T>

A record of all routes and their corresponding handler functions

optional
unnamed 1: RouterOptions<T> = [UNSUPPORTED]

An object containing all of the possible configuration options

Returns

A deno std compatible request handler