Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Router<T>

A use-case agnostic router for holding and matching routes

Type parameters

Hierarchy

  • Router

Index

Properties

Methods

Properties

routes

routes: Route<T>[] = []

The list of routes

Methods

addRoute

  • Adds a route to match when testing paths

    The route handler is the callback that is executed when the program

    Parameters

    Returns void

findRoute

  • findRoute(path: string): undefined | Route<T>
  • Find a route that matches the path, returns undefined if nothing is found

    Parameters

    • path: string

    Returns undefined | Route<T>

runPath

  • runPath(path: string, ...data: T): void
  • Find and run the route handler for the path if any matches are found

    Optionally data can be passed to the handler

    Parameters

    • path: string
    • Rest ...data: T

    Returns void

Generated using TypeDoc