Route

View Source

Summary

A route definition that includes a request method and pattern.

Signature

class Route<method, pattern> {
  constructor(
    method: "ANY" | method,
    pattern: pattern | RoutePattern<pattern>,
  ): Route<method, pattern>;

  // Properties
  method: "ANY" | method;
  pattern: RoutePattern<pattern>;

  // Methods
  href(args: HrefArgs<pattern>): string;
  match(url: string | URL): RoutePatternMatch<pattern> | null;
}

Constructor Params

method

pattern

Properties

method

The HTTP method this route matches.

pattern

The pattern this route matches.

Methods

href(args: HrefArgs): string

Build a URL href for this route using the given parameters.

args

The parameters to use for building the href

match(url: string | URL): RoutePatternMatch | null

Match a URL against this route's pattern.

url

The URL to match