Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Router

import { Router } from "https://raw.githubusercontent.com/Caesar2011/denotrain/master/mod.ts";
class Router<S extends object = Obj, R extends object = Obj> {
private handlers: HandlerObject<S, R>;
private updateRouterHandler: Router[];
protected app?: Application<S, R>;
 
private generateHandlerEntry(
path: Path,
method: RequestMethod | null,
handler: RequestHandler<S, R>,
): HandlerEntry<S, R>;
private *handlerIterator(ctx: Context<S, R>, lifecycle: LifecycleHook);
private matchPath(ctx: Context<S, R>, handler: HandlerEntry<S, R>): {
newSubPath: string;
addParams: {
[_: string]: UrlEncodedValue;
}
;
rawParams: {
[_: string]: string;
}
;
}
| null
;
protected onInit(app: Application<S, R>): void;
public add(
obj: RequestOptions | Path | RequestHandler<S, R>,
method: RequestMethod | null,
...handlers: RequestHandler<S, R>[],
): Router<S, R>;
public delete(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public delete(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public delete(...handlers: RequestHandler<S, R>[]): Router<S, R>;
public delete(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public get(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public get(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public get(...handlers: RequestHandler<S, R>[]): Router<S, R>;
public get(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public async handle(ctx: Context<S, R>, lifecycle: LifecycleHook): Promise<RequestHandlerSuccess>;
public head(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public head(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public head(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public head(...handlers: RequestHandler<S, R>[]): Router<S, R>;
public head(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public patch(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public patch(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public patch(...handlers: RequestHandler<S, R>[]): Router<S, R>;
public patch(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public post(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public post(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public post(...handlers: RequestHandler<S, R>[]): Router<S, R>;
public post(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public put(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public put(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public put(...handlers: RequestHandler<S, R>[]): Router<S, R>;
public put(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public use(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public use(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
public use(...handlers: RequestHandler<S, R>[]): Router<S, R>;
public use(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>;
}

§Type Parameters

§
S extends object = Obj
[src]
§
R extends object = Obj
[src]

§Properties

§
handlers: HandlerObject<S, R>
[src]
§
updateRouterHandler: Router[]
[src]

§Methods

§
generateHandlerEntry(path: Path, method: RequestMethod | null, handler: RequestHandler<S, R>): HandlerEntry<S, R> private
[src]
§
handlerIterator(ctx: Context<S, R>, lifecycle: LifecycleHook) private
[src]
§
matchPath(ctx: Context<S, R>, handler: HandlerEntry<S, R>): {
newSubPath: string;
addParams: {
[_: string]: UrlEncodedValue;
}
;
rawParams: {
[_: string]: string;
}
;
}
| null
private
[src]
§
onInit(app: Application<S, R>): void protected
[src]
§
add(obj: RequestOptions | Path | RequestHandler<S, R>, method: RequestMethod | null, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
§
delete(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
delete(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
delete(...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
delete(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
§
get(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
get(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
get(...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
get(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
§
handle(ctx: Context<S, R>, lifecycle: LifecycleHook): Promise<RequestHandlerSuccess>
[src]
§
patch(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
patch(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
patch(...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
patch(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
§
post(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
post(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
post(...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
post(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
§
put(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
put(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
put(...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
put(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
§
use(path: RequestOptions, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
use(path: Path, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
use(...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]
use(path: RequestOptions | Path | RequestHandler<S, R>, ...handlers: RequestHandler<S, R>[]): Router<S, R>
[src]