This commit is contained in:
2020-08-31 22:33:50 +08:00
parent 32913fa3e1
commit 8b583f2a4d
14 changed files with 450 additions and 102 deletions
+13 -1
View File
@@ -7,6 +7,7 @@ namespace HttpServer\Route;
use HttpServer\Http\Request;
use Exception;
use HttpServer\Application;
use HttpServer\Route\Annotation\Annotation;
use Snowflake\Snowflake;
/**
@@ -36,6 +37,8 @@ class Node extends Application
public $middleware = [];
public $callback = [];
private $_interceptors = [];
/**
* @param $handler
* @return Node
@@ -118,7 +121,7 @@ class Node extends Application
private function getReflect(string $controller, string $action)
{
try {
$reflect = new \ReflectionClass($controller);
$reflect = Snowflake::getDi()->getReflect($controller);
if (!$reflect->isInstantiable()) {
throw new Exception($controller . ' Class is con\'t Instantiable.');
}
@@ -126,6 +129,15 @@ class Node extends Application
if (!empty($action) && !$reflect->hasMethod($action)) {
throw new Exception('method ' . $action . ' not exists at ' . $controller . '.');
}
/** @var Annotation $annotation */
$annotation = Snowflake::createObject(Annotation::class);
if (!empty($methods)) {
$annotations = $annotation->instance($reflect);
if (isset($annotations['Interceptor'])) {
}
}
return [$reflect->newInstance(), $action];
} catch (Exception $exception) {
$this->_error = $exception->getMessage();