diff --git a/utils/middleware/domain.ts b/utils/middleware/domain.ts new file mode 100644 index 0000000..162286d --- /dev/null +++ b/utils/middleware/domain.ts @@ -0,0 +1,15 @@ +import { pogo } from "../../deps.ts" +interface RequestParameters { r: pogo.Request, h: pogo.Toolkit } + +export default ({ r, h }: RequestParameters, domains: string[] | string, handler: any) => { + if (domains.includes(r.host) || domains.includes("*")) { + console.log("Call actual Handler") + return handler(r, h) + + } else { + console.log("Throw Error") + return h.response({ + error: "This Site/Fuction doesn't exist or is not available on the current domain." + }).code(404) + } +} \ No newline at end of file