Skip to main content
Module

x/rutt/mod.ts

🛣️ A tiny and fast http request router designed for use with deno and deno deploy
Go to Latest
import * as rutt from "https://deno.land/x/rutt@0.0.14/mod.ts";

Rutt is a tiny http router designed for use with deno and deno deploy. It is written in about 200 lines of code and is pretty fast, using an extended type of the web-standard URLPattern to provide fast and easy route matching.

Variables

All known HTTP methods.

Functions

Builds an InternalRoutes array from a Routes record.

The default error handler for the router. By default it responds with null body and a status of 500 along with console.error logging the caught error.

The default other handler for the router. By default it responds with null body and a status of 404.

The default unknown method handler for the router. By default it responds with null body, a status of 405 and the Accept header set to all known methods.

A simple and tiny router for deno

Type Aliases

A handler type for anytime the MatchHandler or other parameter handler fails

A handler for HTTP requests. Consumes a request and HandlerContext and returns an optionally async response.

Provides arbitrary context to Handler functions along with connection information.

The internal route object contains either a RegExp pattern or URLPattern which is matched against the incoming request URL. If a match is found for both the pattern and method the associated MatchHandler is called.

An array of internal route objects which the routes record is mapped into. This array is used internally in the router function and can even be passed directly to it if you do not wish to use the routes record or want more fine grained control over matches, for example by using a RegExp pattern instead of a URLPattern.

A handler type for a router path match which gets passed the matched values

A record of route paths and MatchHandlers which are called when a match is found along with it's values.

A handler type for anytime a method is received that is not defined