feat(server): plugins can add middlewares and routes (#1455)
Co-authored-by: RoeHH <git@roeh.ch> Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
co-authored by
RoeHH
Marvin Hagemeister
parent
7dee138bee
commit
50db296fb7
@@ -0,0 +1,18 @@
|
||||
import { AppProps } from "$fresh/server.ts";
|
||||
import { Head } from "../../../../runtime.ts";
|
||||
import { Options } from "../route-plugin.ts";
|
||||
|
||||
export function AppBuilder(options: Options) {
|
||||
return ({ Component }: AppProps) => {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{options.title}</title>
|
||||
</Head>
|
||||
<main class="max-w-screen-md px-4 pt-16 mx-auto">
|
||||
<Component />
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { MiddlewareHandlerContext } from "$fresh/server.ts";
|
||||
|
||||
export async function handler(_req: Request, ctx: MiddlewareHandlerContext) {
|
||||
ctx.state.test = "look, i'm set from a plugin!";
|
||||
const resp = await ctx.next();
|
||||
return resp;
|
||||
}
|
||||
Reference in New Issue
Block a user