Skip to main content

@fartlabs/rt@0.0.2

Minimal HTTP router library based on the URLPattern API.

Works with
It is unknown whether this package works with Bun
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Browsers
JSR Score
100%
Published
5 days ago
indexRouter
class Router
implements RouterInterface
deno add @fartlabs/rt
import { Router } from "@fartlabs/rt";
npx jsr add @fartlabs/rt
import { Router } from "@fartlabs/rt";
yarn dlx jsr add @fartlabs/rt
import { Router } from "@fartlabs/rt";
pnpm dlx jsr add @fartlabs/rt
import { Router } from "@fartlabs/rt";
bunx jsr add @fartlabs/rt
import { Router } from "@fartlabs/rt";

Router is an HTTP router based on the URLPattern API.

Methods

connect<T extends string>(pattern: string, handle: Handle<T>): this

connect appends a router for the CONNECT method to the router.

default(handle: Handle | undefined): this

default sets the router's default handler.

delete<T extends string>(pattern: string, handle: Handle<T>): this

delete appends a router for the DELETE method to the router.

error(handle: ErrorHandle | undefined): this

error sets the router's error handler.

fetch invokes the router for the given request.

get<T extends string>(pattern: string, handle: Handle<T>): this

get appends a router for the GET method to the router.

head<T extends string>(pattern: string, handle: Handle<T>): this

head appends a router for the HEAD method to the router.

options<T extends string>(pattern: string, handle: Handle<T>): this

options appends a router for the OPTIONS method to the router.

patch<T extends string>(pattern: string, handle: Handle<T>): this

patch appends a router for the PATCH method to the router.

post<T extends string>(pattern: string, handle: Handle<T>): this

post appends a router for the POST method to the router.

put<T extends string>(pattern: string, handle: Handle<T>): this

put appends a router for the PUT method to the router.

trace<T extends string>(pattern: string, handle: Handle<T>): this

trace appends a router for the TRACE method to the router.

use(data: Routes | Router): this

use appends a sequence of routers to the router.

with<T extends string>(route: Route<T>): this

with appends a route to the router.

with<T extends string>(match: Match, handle: Handle<T>): this