Skip to content

Commit

Permalink
Merge pull request #3 from krutoo/route-all
Browse files Browse the repository at this point in the history
route.all() method added
  • Loading branch information
krutoo authored Apr 5, 2024
2 parents 3889cdc + 9c259d7 commit 38e2be5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ export function route(pattern: RoutePattern, handler: Handler): Route {
};
}

route.all = route; // for express compatibility
route.get = createRouteFactoryForMethod('get');
route.post = createRouteFactoryForMethod('post');
route.put = createRouteFactoryForMethod('put');
route.delete = createRouteFactoryForMethod('delete');
route.head = createRouteFactoryForMethod('head');
route.options = createRouteFactoryForMethod('options');
route.connect = createRouteFactoryForMethod('connect');
route.patch = createRouteFactoryForMethod('patch');

function createRouteFactoryForMethod(method: string) {
const isSuitableMethod = (request: Request) => request.method.toLowerCase() === method;
Expand Down

0 comments on commit 38e2be5

Please sign in to comment.