webman迁移-优化curd
This commit is contained in:
@@ -249,8 +249,19 @@ Route::add(
|
||||
if (!method_exists($class, $action)) {
|
||||
return new Response(404, ['Content-Type' => 'application/json'], json_encode(['code' => 404, 'msg' => '404 Not Found', 'data' => []], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$instance = new $class();
|
||||
return $instance->$action($request);
|
||||
// 设置 controller 供 get_controller_path、权限校验等使用
|
||||
$request->controller = $class;
|
||||
try {
|
||||
$instance = new $class();
|
||||
return $instance->$action($request);
|
||||
} catch (\Throwable $e) {
|
||||
return new Response(500, ['Content-Type' => 'application/json'], json_encode([
|
||||
'code' => 0,
|
||||
'msg' => $e->getMessage(),
|
||||
'time' => time(),
|
||||
'data' => null,
|
||||
], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user