From 20911617302a195a01243c49821d3a19069eb214 Mon Sep 17 00:00:00 2001 From: filesite Date: Wed, 12 Oct 2022 19:49:02 +0800 Subject: [PATCH] json body post support --- controller/Controller.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/controller/Controller.php b/controller/Controller.php index 77ce9fa..9c3aa81 100644 --- a/controller/Controller.php +++ b/controller/Controller.php @@ -10,6 +10,16 @@ Class Controller { if (!empty(FSC::$app['config']['default_layout'])) { $this->layout = FSC::$app['config']['default_layout']; } + + //json body auto serialization to $_POST + try { + $json = file_get_contents('php://input'); + $jsonData = json_decode($json, true); + + if (!empty($jsonData)) { + $_POST = array_merge($_POST, $jsonData); + } + }catch(Exception $e) {} } function __destruct() {