feat(server): throwing Deno.errors.NotFound triggers 404 (#1984)
This commit is contained in:
@@ -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.";
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(_req, _ctx) {
|
||||
throw new Deno.errors.NotFound();
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user