变更
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Kiri\Router\Annotate;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionException;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)]
|
||||
class Route extends AbstractRequestMethod implements InjectRouteInterface
|
||||
@@ -15,7 +16,7 @@ class Route extends AbstractRequestMethod implements InjectRouteInterface
|
||||
* @param string $path
|
||||
* @param RequestMethod $method
|
||||
*/
|
||||
public function __construct(readonly public string $path, readonly public RequestMethod $method)
|
||||
public function __construct(readonly public string $path, readonly public RequestMethod $method, readonly public string $version = 'v1')
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,11 +25,13 @@ class Route extends AbstractRequestMethod implements InjectRouteInterface
|
||||
* @param object $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(object $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
Router::addRoute($this->method, $this->path, [$class, $method]);
|
||||
$path = $this->version . '/' . ltrim($this->path, '/');
|
||||
|
||||
Router::addRoute([$this->method], $path, [$class, $method]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user