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);