Add Domain 'Middleware'
This commit is contained in:
parent
6af6a3db28
commit
1c1ec2f6bc
1 changed files with 7 additions and 1 deletions
|
@ -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
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue