From 68f9981680844e876636369cb07137b351b23989 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 18 Jan 2025 20:59:00 +0200 Subject: feat(controllers): Meta now doesn't call a function if it doesn't exist --- controllers/meta.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/controllers/meta.php b/controllers/meta.php index ea26c30..e567ac3 100644 --- a/controllers/meta.php +++ b/controllers/meta.php @@ -4,9 +4,15 @@ foreach (glob("../models/*.php") as $filename) { include $filename; } +function call_handler(string $name) { + if (function_exists($name)) { + call_user_func($name); + } +} + match ($_SERVER['REQUEST_METHOD']) { - 'POST' => on_post(), - 'GET' => on_get(), - 'PUT' => on_put(), - 'DELETE' => on_delete(), + 'POST' => call_handler('on_post'), + 'GET' => call_handler('on_get'), + 'PUT' => call_handler('on_put'), + 'DELETE' => call_handler('on_delete'), }; -- cgit v1.2.3