Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

FindMyWay unstable

A radix-tree HTTP router used by the unstable HTTP routing modules.

5 exports Since v4.0.0 Source

Constructors

make

unstable
Since v4.0.0

Creates an empty mutable router.

Signature

declare const make: <A>(options?: Partial<RouterConfig>) => Router<A>

Models

FindResult

interface unstable
Since v4.0.0

Result of a successful route lookup.

Signature

interface FindResult<A> {
readonly handler: A;
readonly params: Record<string, string | undefined>;
readonly searchParams: Record<string, string | Array<string>>;
}

PathInput

type unstable
Since v4.0.0

Route path accepted by the router.

Signature

type PathInput = `/${string}` | "*"

Router

interface unstable
Since v4.0.0

Mutable router used to register and resolve route handlers.

Signature

interface Router<A> {
readonly all: (path: PathInput, handler: A) => void;
readonly find: (method: string, url: string) => FindResult<A> | undefined;
readonly has: (method: string, url: string) => boolean;
readonly on: (method: string | Iterable<string, any, any>, path: PathInput, handler: A) => void;
}

RouterConfig

interface unstable
Since v4.0.0

Configuration for router path matching.

Signature

interface RouterConfig {
readonly caseSensitive: boolean;
readonly ignoreDuplicateSlashes: boolean;
readonly ignoreTrailingSlash: boolean;
readonly maxParamLength: number;
}