Skip to content

Commit

Permalink
feat(router): add ws alias for GET route
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed May 3, 2021
1 parent 070b139 commit b11a593
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export type RouteParams<T extends string> =
export declare class Router {
add<T extends RegExp>(method: Method, route: T, handler: Handler<Params>): void;
add<T extends string>(method: Method, route: T, handler: Handler<RouteParams<T>>): void;
ws<T extends RegExp>(route: T, handler: Handler<Params>): void;
ws<T extends string>(route: T, handler: Handler<RouteParams<T>>): void;
find(method: Method, pathname: string): Route|void;
run(event: FetchEvent): Promise<Response>;
onerror(req: ServerRequest, res: ServerResponse, status?: number, error?: Error): Promisable<Response>;
Expand Down
4 changes: 4 additions & 0 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export function Router(): RR {
}
},

ws(route: string, handler: Handler) {
$.add('GET', route, handler);
},

find(method, pathname) {
let params: Params = {};
let tmp, dict, rgx, val, match;
Expand Down

0 comments on commit b11a593

Please sign in to comment.