改名
This commit is contained in:
@@ -15,6 +15,7 @@ use Annotation\Route\Middleware as RMiddleware;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Annotation\Route\Limits;
|
use Annotation\Route\Limits;
|
||||||
use HttpServer\Route\Dispatch\Dispatch;
|
use HttpServer\Route\Dispatch\Dispatch;
|
||||||
|
use Snowflake\Core\JSON;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,12 +55,21 @@ class Middleware
|
|||||||
*/
|
*/
|
||||||
public function getGenerate(Node $node): mixed
|
public function getGenerate(Node $node): mixed
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
if (is_array($node->handler) && is_object($node->handler[0])) {
|
if (is_array($node->handler) && is_object($node->handler[0])) {
|
||||||
$this->set_attributes($node);
|
$this->set_attributes($node);
|
||||||
}
|
}
|
||||||
return $node->callback = Reduce::reduce(function () use ($node) {
|
return $node->callback = Reduce::reduce(function () use ($node) {
|
||||||
return Dispatch::create($node->handler, func_get_args())->dispatch();
|
return Dispatch::create($node->handler, func_get_args())->dispatch();
|
||||||
}, $this->annotation($node));
|
}, $this->annotation($node));
|
||||||
|
} catch (\Throwable $exception) {
|
||||||
|
return $node->callback = function () use ($exception) {
|
||||||
|
return JSON::to(500, $exception->getMessage(), [
|
||||||
|
'file' => $exception->getFile(),
|
||||||
|
'line' => $exception->getLine()
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user