mirror of
https://github.com/denoland/deno.git
synced 2024-12-28 10:09:20 -05:00
34 lines
933 B
TypeScript
34 lines
933 B
TypeScript
import type { Router, Result } from '../../router';
|
|
interface Hint {
|
|
components: string[];
|
|
regExpComponents: Array<true | string>;
|
|
componentsLength: number;
|
|
endWithWildcard: boolean;
|
|
paramIndexList: number[];
|
|
maybeHandler: boolean;
|
|
namedParams: [number, string, string][];
|
|
}
|
|
interface HandlerWithSortIndex<T> {
|
|
handler: T;
|
|
index: number;
|
|
}
|
|
interface Route<T> {
|
|
method: string;
|
|
path: string;
|
|
hint: Hint;
|
|
handlers: HandlerWithSortIndex<T>[];
|
|
middleware: HandlerWithSortIndex<T>[];
|
|
paramAliasMap: Record<string, string[]>;
|
|
}
|
|
export declare class RegExpRouter<T> implements Router<T> {
|
|
routeData?: {
|
|
index: number;
|
|
routes: Route<T>[];
|
|
methods: Set<string>;
|
|
};
|
|
add(method: string, path: string, handler: T): void;
|
|
match(method: string, path: string): Result<T> | null;
|
|
private buildAllMatchers;
|
|
private buildMatcher;
|
|
}
|
|
export {};
|