diff options
| author | Syndamia <kamen@syndamia.com> | 2025-01-26 22:17:28 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-01-26 22:21:31 +0200 |
| commit | 6082680e8655efcec0b255047b5b27064bf9fc3f (patch) | |
| tree | 6960ff83a60a63c86f714cfebfbd0538750832a7 /controllers/meta.php | |
| parent | edf446fae669f3370609f5a955c3d6c863a93524 (diff) | |
| download | nowayforward_human-6082680e8655efcec0b255047b5b27064bf9fc3f.tar nowayforward_human-6082680e8655efcec0b255047b5b27064bf9fc3f.tar.gz nowayforward_human-6082680e8655efcec0b255047b5b27064bf9fc3f.zip | |
feat(controllers): Simplified non-standard method request logic
Diffstat (limited to 'controllers/meta.php')
| -rw-r--r-- | controllers/meta.php | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/controllers/meta.php b/controllers/meta.php index 91a8ade..46550d3 100644 --- a/controllers/meta.php +++ b/controllers/meta.php @@ -8,16 +8,21 @@ function call_handler(string $name) { $TOKEN = (array_key_exists('token', $_COOKIE)) ? ($_COOKIE['token'] ?? "") : (""); -function request_handler() { - if ($_SERVER['REQUEST_METHOD'] === 'POST') { - if (array_key_exists('method', $_POST)) { - switch ($_POST['method']) { - case 'PUT': call_handler('Controller\on_put'); return; - case 'DELETE': call_handler('Controller\on_delete'); return; - case 'PATCH': call_handler('Controller\on_patch'); return; - } - } - call_handler('Controller\on_post'); +$METHOD = null; +if (array_key_exists('method', $_POST)) { + $METHOD = $_POST; +} +else if (array_key_exists('method', $_GET)) { + $METHOD = $_GET; +} + +if ($METHOD !== null) { + switch ($METHOD['method']) { + case 'PUT': call_handler('Controller\on_put'); break; + case 'DELETE': call_handler('Controller\on_delete'); break; + case 'PATCH': call_handler('Controller\on_patch'); break; } } -request_handler(); +else if ($_SERVER['REQUEST_METHOD'] === 'POST') { + call_handler('Controller\on_post'); +} |
