You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lib/src/http/routing/ActivatedRoute.ts

24 lines
627 B

import {ErrorWithContext} from "@extollo/util";
import {Route} from "./Route";
export class ActivatedRoute {
public readonly params: {[key: string]: string}
constructor(
public readonly route: Route,
public readonly path: string
) {
const params = route.extract(path)
if ( !params ) {
const error = new ErrorWithContext('Cannot get params for route. Path does not match.')
error.context = {
matchedRoute: String(route),
requestPath: path,
}
throw error
}
this.params = params
}
}