Add support for deepmatch routes

This commit is contained in:
garrettmills
2020-07-30 08:17:49 -05:00
parent 42e8b36df4
commit 7611c1b2bf
6 changed files with 77 additions and 8 deletions

View File

@@ -13,6 +13,7 @@ import {Canonical} from './Canonical.ts'
import {Logging} from '../service/logging/Logging.ts'
import {Canon} from './Canon.ts'
import {isBindable} from '../lifecycle/AppClass.ts'
import {DeepmatchRoute} from "../http/routing/DeepmatchRoute.ts";
export type RouteHandler = (request: Request) => Request | Promise<Request> | ResponseFactory | Promise<ResponseFactory> | void | Promise<void>
export type RouteHandlers = RouteHandler[]
@@ -138,11 +139,11 @@ export default class Routing extends LifecycleUnit {
public build_route(base: string): Route {
if ( !base.includes(':') && !base.includes('*') ) {
return new SimpleRoute(base)
} else if ( base.includes('**') ) {
return new DeepmatchRoute(base)
} else {
return new ComplexRoute(base)
}
// TODO deep-match route
}
public match(incoming: string): Route | undefined {