feat(server): throwing Deno.errors.NotFound triggers 404 (#1984)

This commit is contained in:
Reed von Redwitz
2023-10-30 18:00:57 +01:00
committed by GitHub
parent 781247b180
commit f39e0d4218
8 changed files with 296 additions and 147 deletions
@@ -0,0 +1,10 @@
import { MiddlewareHandlerContext } from "$fresh/server.ts";
// handlers are supposed to return something, so in order to make type checker on the manifest happy, we'll use any to escape it
export function handler(
_req: Request,
_ctx: MiddlewareHandlerContext,
// deno-lint-ignore no-explicit-any
): any {
throw new Deno.errors.NotFound();
}
@@ -0,0 +1,5 @@
import { defineRoute } from "$fresh/server.ts";
export default defineRoute((req, ctx) => {
return "This never gets shown, because the middleware throws an error.";
});
+7
View File
@@ -0,0 +1,7 @@
import { Handlers } from "$fresh/server.ts";
export const handler: Handlers = {
GET(_req, _ctx) {
throw new Deno.errors.NotFound();
},
};