Skip to content

Commit

Permalink
route-all
Browse files Browse the repository at this point in the history
- `server`: `route.all` method added
- `server`: `route.patch` method added
  • Loading branch information
krutoo committed Apr 5, 2024
1 parent 3889cdc commit 9c259d7
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 9c259d7

Please sign in to comment.