改名
This commit is contained in:
@@ -5,8 +5,9 @@ namespace Annotation\Route;
|
||||
|
||||
|
||||
use Annotation\Attribute;
|
||||
use Http\Handler\Abstracts\HandlerManager;
|
||||
use Http\Handler\Handler;
|
||||
use Http\Route\Router;
|
||||
use Kiri\Kiri;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Route extends Attribute
|
||||
{
|
||||
@@ -19,6 +20,8 @@ use Kiri\Kiri;
|
||||
*/
|
||||
public function __construct(public string $uri, public string $method, public string $version = 'v.1.0')
|
||||
{
|
||||
$this->uri = '/' . ltrim($this->uri, '/');
|
||||
$this->method = strtoupper($this->method);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,16 +29,12 @@ use Kiri\Kiri;
|
||||
* @param mixed $class
|
||||
* @param mixed|null $method
|
||||
* @return Router
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function execute(mixed $class, mixed $method = null): Router
|
||||
{
|
||||
// TODO: Implement setHandler() method.
|
||||
$router = Kiri::getDi()->get(Router::class);
|
||||
if (is_string($class)) {
|
||||
$class = di($class);
|
||||
}
|
||||
$router->addRoute($this->uri, [$class, $method], strtoupper($this->method));
|
||||
return $router;
|
||||
HandlerManager::add($this->uri, $this->method, new Handler($this->uri, [$class, $method]));
|
||||
return parent::execute($class, $method);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user