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,22 @@
|
||||
import { Plugin } from "$fresh/server.ts";
|
||||
import { handler as testMiddleware } from "./sample_routes/_middleware.ts";
|
||||
import { AppBuilder } from "./sample_routes/AppBuilder.tsx";
|
||||
export type { Options };
|
||||
|
||||
interface Options {
|
||||
title: string;
|
||||
}
|
||||
|
||||
export default function routePlugin(options: Options): Plugin {
|
||||
return {
|
||||
name: "routePlugin",
|
||||
middlewares: [{
|
||||
middleware: { handler: testMiddleware },
|
||||
path: "/",
|
||||
}],
|
||||
routes: [{
|
||||
path: "/_app",
|
||||
component: AppBuilder(options),
|
||||
}],
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user