变更
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)]
|
||||
class Aspect
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param string $aspect
|
||||
*/
|
||||
public function __construct(readonly public string $aspect)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,12 +18,11 @@ class Delete extends AbstractRequestMethod implements InjectRouteInterface
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
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
|
||||
@@ -34,7 +33,9 @@ class Delete extends AbstractRequestMethod implements InjectRouteInterface
|
||||
public function dispatch(object $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
Router::addRoute(RequestMethod::REQUEST_DELETE, $this->path, [$class, $method]);
|
||||
$path = $this->version . '/' . ltrim($this->path, '/');
|
||||
|
||||
Router::addRoute(RequestMethod::REQUEST_DELETE, $path, [$class, $method]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,12 +19,11 @@ class Head extends AbstractRequestMethod implements InjectRouteInterface
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
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
|
||||
@@ -35,7 +34,9 @@ class Head extends AbstractRequestMethod implements InjectRouteInterface
|
||||
public function dispatch(object $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
Router::addRoute(RequestMethod::REQUEST_HEAD, $this->path, [$class, $method]);
|
||||
$path = $this->version . '/' . ltrim($this->path, '/');
|
||||
|
||||
Router::addRoute(RequestMethod::REQUEST_HEAD, $path, [$class, $method]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,12 +19,11 @@ class Options extends AbstractRequestMethod implements InjectRouteInterface
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
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
|
||||
@@ -35,7 +34,9 @@ class Options extends AbstractRequestMethod implements InjectRouteInterface
|
||||
public function dispatch(object $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
Router::addRoute(RequestMethod::REQUEST_OPTIONS, $this->path, [$class, $method]);
|
||||
$path = $this->version . '/' . ltrim($this->path, '/');
|
||||
|
||||
Router::addRoute(RequestMethod::REQUEST_OPTIONS, $path, [$class, $method]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,12 +14,11 @@ class Post 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')
|
||||
{
|
||||
}
|
||||
|
||||
@@ -34,7 +33,9 @@ class Post extends AbstractRequestMethod implements InjectRouteInterface
|
||||
public function dispatch(object $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
Router::addRoute(RequestMethod::REQUEST_POST, $this->path, [$class, $method]);
|
||||
$path = $this->version . '/' . ltrim($this->path, '/');
|
||||
|
||||
Router::addRoute(RequestMethod::REQUEST_POST, $path, [$class, $method]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class Put extends AbstractRequestMethod implements InjectRouteInterface
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function __construct(readonly public string $path)
|
||||
public function __construct(readonly public string $path, readonly public string $version = 'v1')
|
||||
{
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ class Put extends AbstractRequestMethod implements InjectRouteInterface
|
||||
public function dispatch(object $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
Router::addRoute(RequestMethod::REQUEST_PUT, $this->path, [$class, $method]);
|
||||
$path = $this->version . '/' . ltrim($this->path, '/');
|
||||
|
||||
Router::addRoute(RequestMethod::REQUEST_PUT, $path, [$class, $method]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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