Add Domain 'Middleware'

This commit is contained in:
Joshua 2022-09-18 15:06:31 +02:00
parent 6af6a3db28
commit 1c1ec2f6bc

View file

@ -1,5 +1,6 @@
import { pogo, serve } from "../deps.ts";
import routes from "./routes.generated.ts"
import domain from "../utils/middleware/domain.ts";
const env = {
port: Number(Deno.env.get("POGO_PORT")) || 3000,
@ -16,7 +17,12 @@ server.router.get('/static/{file*}', (r, h) => {
routes.forEach(route => {
server.route({ method: route.method, handler: route.handler, path: route.route })
server.route({
method: route.method, handler: (r, h) => {
if (!route.domains) route.domains = ["*"]
return domain({ r, h }, route.domains, route.handler)
}, path: route.route
})
})