From 42ff8adee83fa3840c256d78a177b55309983f3b Mon Sep 17 00:00:00 2001 From: hide_d Date: Fri, 25 Feb 2022 01:54:22 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20api.php=20=ED=98=B8=EC=B6=9C=EC=97=90?= =?UTF-8?q?=EC=84=9C=20path=EB=A5=BC=20=EA=B2=BD=EB=A1=9C=EB=A1=9C=20?= =?UTF-8?q?=EC=A7=80=EC=A0=95=ED=95=98=EB=8A=94=20=EB=B0=A9=EC=8B=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.php | 2 +- hwe/api.php | 2 +- hwe/ts/util/callSammoAPI.ts | 7 ++----- src/sammo/APIHelper.php | 35 +++++++++++++++++++++++++---------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/api.php b/api.php index ce0bb9f8..9b9ef3b7 100644 --- a/api.php +++ b/api.php @@ -9,4 +9,4 @@ if (!class_exists('\\sammo\\RootDB')) { Json::dieWithReason('No DB'); } -APIHelper::launch(dirname(__FILE__)); \ No newline at end of file +APIHelper::launch(dirname(__FILE__), $_GET['path']??null); \ No newline at end of file diff --git a/hwe/api.php b/hwe/api.php index a6d67bae..7f91b80a 100644 --- a/hwe/api.php +++ b/hwe/api.php @@ -5,4 +5,4 @@ namespace sammo; include "lib.php"; include "func.php"; -APIHelper::launch(dirname(__FILE__)); \ No newline at end of file +APIHelper::launch(dirname(__FILE__), $_GET['path']??null); \ No newline at end of file diff --git a/hwe/ts/util/callSammoAPI.ts b/hwe/ts/util/callSammoAPI.ts index 2598daee..49708cd1 100644 --- a/hwe/ts/util/callSammoAPI.ts +++ b/hwe/ts/util/callSammoAPI.ts @@ -16,13 +16,10 @@ export async function callSammoAPIgetMessage()); } - if(!$input){ - Json::dieWithReason("input이 비어있습니다. {$rawInput}"); + if($actionPath !== null){ + if ($input && !is_array($input)) { + Json::dieWithReason('args가 array가 아닙니다.' . gettype($input)); + } + if(!$input){ + $input = []; + } + $actionArgs = $input; + } + else{ + if(!$input){ + Json::dieWithReason("input이 비어있습니다. {$rawInput}"); + } + + if (!key_exists('path', $input)) { + Json::dieWithReason('path가 지정되지 않았습니다.'); + } + $actionPath = $input['path']; + + if (key_exists('args', $input) && !is_array($input['args'])) { + Json::dieWithReason('args가 array가 아닙니다.' . gettype($input['args'])); + } + $actionArgs = $input['args'] ?? null; } - if (!key_exists('path', $input)) { - Json::dieWithReason('path가 지정되지 않았습니다.'); - } - if (key_exists('args', $input) && !is_array($input['args'])) { - Json::dieWithReason('args가 array가 아닙니다.' . gettype($input['args'])); - } try { - $obj = buildAPIExecutorClass($input['path'], $rootPath, $input['args'] ?? []); + $obj = buildAPIExecutorClass($actionPath, $rootPath, $actionArgs); $validateResult = $obj->validateArgs(); if ($validateResult !== null) { Json::dieWithReason($validateResult);