Skip to content

Commit

Permalink
add Route.options (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kota Ogihara authored Mar 16, 2021
1 parent 3b34c05 commit 63068dd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ export interface Router extends Route {
/** Register DELETE route */
delete(pattern: string | RegExp, ...handlers: RouteHandler[]): void;

/** Register OPTIONS route */
options(pattern: string | RegExp, ...handlers: RouteHandler[]): void;

/** Accept ws upgrade */
ws(pattern: string | RegExp, handler: WebSocketHandler): void;
ws(
Expand Down Expand Up @@ -152,6 +155,10 @@ export function createRouter(): Router {
routes.push({ pattern, methods: ["DELETE"], handlers });
}

function options(pattern: string | RegExp, ...handlers: RouteHandler[]) {
routes.push({ pattern, methods: ["OPTIONS"], handlers });
}

function use(...handlers: ServeHandler[]) {
middlewareList.push(...handlers);
}
Expand Down

0 comments on commit 63068dd

Please sign in to comment.