modify
This commit is contained in:
@@ -157,8 +157,11 @@ class Response extends HttpService
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function getBuilder(mixed $data, SResponse $response): static
|
public function getBuilder(mixed $data, SResponse $response = null): static
|
||||||
{
|
{
|
||||||
|
if ($response === null) {
|
||||||
|
return $this->setContent($data);
|
||||||
|
}
|
||||||
$response->setStatusCode($this->statusCode);
|
$response->setStatusCode($this->statusCode);
|
||||||
if (!isset($response->header['Content-Type'])) {
|
if (!isset($response->header['Content-Type'])) {
|
||||||
$response->header('Content-Type', $this->getResponseFormat());
|
$response->header('Content-Type', $this->getResponseFormat());
|
||||||
|
|||||||
@@ -144,10 +144,11 @@ class Application extends BaseApplication
|
|||||||
if (!($class instanceof Command)) {
|
if (!($class instanceof Command)) {
|
||||||
scan_directory(directory('app'), 'App');
|
scan_directory(directory('app'), 'App');
|
||||||
}
|
}
|
||||||
response()->send($manager->execCommand($class));
|
$data = response()->getBuilder($manager->execCommand($class));
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
response()->send(logger()->exception($exception));
|
$data = response()->getBuilder(logger()->exception($exception));
|
||||||
} finally {
|
} finally {
|
||||||
|
print_r($data);
|
||||||
Timer::clearAll();
|
Timer::clearAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -590,10 +590,10 @@ if (!function_exists('name')) {
|
|||||||
if (!function_exists('response')) {
|
if (!function_exists('response')) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Response|stdClass
|
* @return Response
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
function response(): Response|stdClass
|
function response(): Response
|
||||||
{
|
{
|
||||||
if (!Context::hasContext(Response::class)){
|
if (!Context::hasContext(Response::class)){
|
||||||
return Context::setContext(Response::class, new Response());
|
return Context::setContext(Response::class, new Response());
|
||||||
|
|||||||
Reference in New Issue
Block a user