From 6b271db30e53011f08196f8b03a1be21f3711669 Mon Sep 17 00:00:00 2001 From: LitoMore Date: Wed, 25 Sep 2024 06:21:01 +0800 Subject: [PATCH] docs(http/unstable): add example of multiple request methods on route --- http/mod.ts | 7 ++++++- http/unstable_route.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/http/mod.ts b/http/mod.ts index 0ab47649ffca..66c7b932bbb7 100644 --- a/http/mod.ts +++ b/http/mod.ts @@ -79,7 +79,12 @@ * { * pattern: new URLPattern({ pathname: "/static/*" }), * handler: (req: Request) => serveDir(req) - * } + * }, + * { + * method: ["GET", "HEAD"], + * pattern: new URLPattern({ pathname: "/api" }), + * handler: (req: Request) => new Response(req.method === 'HEAD' ? null : 'ok'), + * }, * ]; * * function defaultHandler(_req: Request) { diff --git a/http/unstable_route.ts b/http/unstable_route.ts index 25111f3a1f63..4e93d4b446f3 100644 --- a/http/unstable_route.ts +++ b/http/unstable_route.ts @@ -63,8 +63,8 @@ export interface Route { * handler: (req: Request) => serveDir(req) * }, * { - * pattern: new URLPattern({ pathname: "/api" }), * method: ["GET", "HEAD"], + * pattern: new URLPattern({ pathname: "/api" }), * handler: (req: Request) => new Response(req.method === 'HEAD' ? null : 'ok'), * }, * ];