aboutsummaryrefslogtreecommitdiff
path: root/controllers/meta.php
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/meta.php')
-rw-r--r--controllers/meta.php20
1 files changed, 15 insertions, 5 deletions
diff --git a/controllers/meta.php b/controllers/meta.php
index e20bbfc..91a8ade 100644
--- a/controllers/meta.php
+++ b/controllers/meta.php
@@ -6,8 +6,18 @@ function call_handler(string $name) {
}
}
-switch ($_SERVER['REQUEST_METHOD']) {
- case 'POST': call_handler('Controller\on_post'); break;
- case 'PUT': call_handler('Controller\on_put'); break;
- case 'DELETE': call_handler('Controller\on_delete'); break;
-};
+$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');
+ }
+}
+request_handler();