fix: middleware state reset between middlewares (#1500)

This commit is contained in:
Marvin Hagemeister
2023-07-24 11:03:11 +02:00
committed by GitHub
parent 0b96db4bae
commit 38d4b90091
10 changed files with 277 additions and 13 deletions
@@ -0,0 +1,6 @@
import { MiddlewareHandlerContext } from "$fresh/server.ts";
export const handler = (_req: Request, ctx: MiddlewareHandlerContext) => {
ctx.state.handler2 = "it works";
return ctx.next();
};
@@ -0,0 +1,10 @@
import { HandlerContext, PageProps } from "$fresh/server.ts";
export const handler = (_req: Request, ctx: HandlerContext) => {
ctx.state.handler3 = "it works";
return ctx.render();
};
export default function Page(props: PageProps) {
return <pre>{JSON.stringify(props.state,null,2)}</pre>;
}