Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/allo_routing/mod.ts>MaskRouter

🦕 Routing solution for Deno
Latest
class MaskRouter
implements IRouter
extends Router
Re-export
import { MaskRouter } from "https://deno.land/x/allo_routing@v2.2.3/mod.ts";

Class MaskRouter is a router that mathing url by mask.

Some part of the mask can be optional. This part is closed to [ and ].

Mask may contains parameters. Parameter is defined by < and > symbols. In the parameter you can specific the default value. <param=default> Also you can define regular expression for value validation.<param=default regexp>

Examples:

  • product[/detail]
  • [product[/detail]]
  • product/<id>
  • page/<id=123 \\d+>

Constructors

new
MaskRouter(
mask: string,
serveResponse: ServeResponseType,
options?: RouterOptions,
)

Methods

getMask(): string
match(req: Request): boolean

Return true if pathname of request matches mask.

recontructPathname(params: Record<string, string>): string

Return Response.