This commit is contained in:
2023-04-19 12:35:39 +08:00
parent a16bb3a19c
commit aa8fb228cc
12 changed files with 151 additions and 55 deletions
+5 -5
View File
@@ -14,28 +14,28 @@ class Get extends AbstractRequestMethod implements InjectRouteInterface
{
/**
* @param string $path
* @param string $version
*/
public function __construct(readonly public string $path)
public function __construct(readonly public string $path, readonly public string $version = 'v1')
{
}
/**
* @param object $class
* @param string $method
* @return void
* @throws ReflectionException
* @throws Exception
* @throws ReflectionException
*/
public function dispatch(object $class, string $method): void
{
// TODO: Implement dispatch() method.
Router::addRoute(RequestMethod::REQUEST_GET, $this->path, [$class, $method]);
$path = $this->version . '/' . ltrim($this->path, '/');
Router::addRoute(RequestMethod::REQUEST_GET, $path, [$class, $method]);
}
}