From 6eeb20c7a3aec3a4b459090b7ded23a3271fb750 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Mon, 14 Jul 2025 18:11:20 +0200 Subject: [PATCH] Revert "feat: support overwriting default 404 handler (#3081)" (#3093) This reverts commit 0b3546f2013c58880084a72d89f76a7a3363d039. Reverting this because it will be superseded by https://github.com/denoland/fresh/pull/3086 --- src/app.ts | 10 ++-------- src/app_test.tsx | 12 ------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/app.ts b/src/app.ts index 72543b1a..8f2fd4ee 100644 --- a/src/app.ts +++ b/src/app.ts @@ -245,13 +245,7 @@ export class App { return this; } - /** - * Create handler function for `Deno.serve` or to be used in - * testing. - * @param {() => Promise} [nextFn] overwrite default 404 handler - * @returns {Deno.ServeHandler} - */ - handler(nextFn?: () => Promise): ( + handler(): ( request: Request, info?: Deno.ServeHandlerInfo, ) => Promise { @@ -282,7 +276,7 @@ export class App { const next = matched.patternMatch && !matched.methodMatch ? DEFAULT_NOT_ALLOWED_METHOD - : nextFn ?? DEFAULT_NOT_FOUND; + : DEFAULT_NOT_FOUND; const { params, handlers, pattern } = matched; const ctx = new FreshReqContext( diff --git a/src/app_test.tsx b/src/app_test.tsx index 4c0eec84..7bb10f20 100644 --- a/src/app_test.tsx +++ b/src/app_test.tsx @@ -532,15 +532,3 @@ Deno.test("App - adding Island should convert to valid export names", () => { fn: component3, }); }); - -Deno.test("App - overwrite default 404 handler", async () => { - const app = new App().get("/foo", () => new Response("foo")); - - const server = new FakeServer( - app.handler(() => Promise.resolve(new Response("bar"))), - ); - - const res = await server.get("/invalid"); - const text = await res.text(); - expect(text).toEqual("bar"); -});