fix(server): middleware order incorrect (#1280)

This commit is contained in:
Reed von Redwitz
2023-07-10 15:19:52 +02:00
committed by GitHub
parent 724c81f2c7
commit d4c2258eb6
8 changed files with 207 additions and 22 deletions
@@ -0,0 +1,13 @@
import { Handlers, PageProps } from "$fresh/server.ts";
export const handler: Handlers = {
async GET(_req: Request, ctx) {
const order = ctx.state.middlewareNestingOrder as string;
const resp = await ctx.render(order + "4");
return resp;
},
};
export default function Page(props: PageProps) {
return <div>{props.data}</div>;
}
@@ -0,0 +1,7 @@
import { MiddlewareHandlerContext } from "$fresh/server.ts";
export async function handler(_req: Request, ctx: MiddlewareHandlerContext) {
ctx.state.middlewareNestingOrder += "3";
const resp = await ctx.next();
return resp;
}
@@ -0,0 +1,7 @@
import { MiddlewareHandlerContext } from "$fresh/server.ts";
export async function handler(_req: Request, ctx: MiddlewareHandlerContext) {
ctx.state.middlewareNestingOrder += "2";
const resp = await ctx.next();
return resp;
}
@@ -0,0 +1,7 @@
import { MiddlewareHandlerContext } from "$fresh/server.ts";
export async function handler(_req: Request, ctx: MiddlewareHandlerContext) {
ctx.state.middlewareNestingOrder = "1";
const resp = await ctx.next();
return resp;
}