feat: layered and scoped middleware and context state (#139)

Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
Sylvain Cau
2022-04-23 22:07:40 +02:00
committed by GitHub
co-authored by Luca Casonato
parent b36f2c1a43
commit 8d4e77f4ac
19 changed files with 422 additions and 58 deletions
@@ -0,0 +1,16 @@
import { MiddlewareHandlerContext } from "../../../server_deps.ts";
interface State {
root: string;
layer1: string;
layer2: string;
}
export async function handler(
_req: Request,
ctx: MiddlewareHandlerContext<State>,
) {
ctx.state.layer2 = "layer2_mw";
const resp = await ctx.next();
return resp;
}