Add Domain middleware

This commit is contained in:
Joshua 2022-09-18 15:07:41 +02:00
parent 7e8891f706
commit 3645dc5c5f

View file

@ -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)
}
}