I want to disable a portal page(www) depending on a condition

I have created a Single Doctype for storing. Now I want to use its data and enable/disable a page. Does Frappe have a middleware where I could reroute the request dynamically?

note: I could check the single doctype on every page. But, want to address it once for all those pages and not on each page individually.