Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
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://deno.land/x/fresh@1.1.3/src/server/deps.ts";
const { router } = rutt;

A simple and tiny router for deno

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
other: Handler<T> = [UNSUPPORTED]

An optional parameter which contains a handler for anything that doesn't match the routes parameter

optional
error: ErrorHandler<T> = [UNSUPPORTED]

An optional parameter which contains a handler for any time it fails to run the default request handling code

optional
unknownMethod: UnknownMethodHandler<T> = [UNSUPPORTED]

An optional parameter which contains a handler for any time a method that is not defined is used

Returns

A deno std compatible request handler