This commit is contained in:
xl
2024-08-29 15:56:30 +08:00
parent abb69cff20
commit 2058849059
7 changed files with 7 additions and 18 deletions
+1 -3
View File
@@ -28,14 +28,12 @@ class Delete extends AbstractRequestMethod implements InjectMethodInterface
*/ */
public function dispatch(string $class, string $method): void public function dispatch(string $class, string $method): void
{ {
$controller = \Kiri::getDi()->get($class);
// TODO: Implement dispatch() method. // TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/'); $path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) { if (!empty($this->version)) {
$path = '/' . trim($this->version) . $path; $path = '/' . trim($this->version) . $path;
} }
Router::addRoute(RequestMethod::REQUEST_DELETE, $path, [$controller, $method]); Router::addRoute(RequestMethod::REQUEST_DELETE, $path, [$class, $method]);
} }
+1 -3
View File
@@ -28,14 +28,12 @@ class Get extends AbstractRequestMethod implements InjectMethodInterface
*/ */
public function dispatch(string $class, string $method): void public function dispatch(string $class, string $method): void
{ {
$controller = \Kiri::getDi()->get($class);
// TODO: Implement dispatch() method. // TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/'); $path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) { if (!empty($this->version)) {
$path = '/' . trim($this->version) . $path; $path = '/' . trim($this->version) . $path;
} }
Router::addRoute(RequestMethod::REQUEST_GET, $path, [$controller, $method]); Router::addRoute(RequestMethod::REQUEST_GET, $path, [$class, $method]);
} }
} }
+1 -2
View File
@@ -29,13 +29,12 @@ class Head extends AbstractRequestMethod implements InjectMethodInterface
*/ */
public function dispatch(string $class, string $method): void public function dispatch(string $class, string $method): void
{ {
$controller = Kiri::getDi()->get($class);
// TODO: Implement dispatch() method. // TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/'); $path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) { if (!empty($this->version)) {
$path = '/' . trim($this->version) . $path; $path = '/' . trim($this->version) . $path;
} }
Router::addRoute(RequestMethod::REQUEST_HEAD, $path, [$controller, $method]); Router::addRoute(RequestMethod::REQUEST_HEAD, $path, [$class, $method]);
} }
+1 -3
View File
@@ -30,14 +30,12 @@ class Options extends AbstractRequestMethod implements InjectMethodInterface
*/ */
public function dispatch(string $class, string $method): void public function dispatch(string $class, string $method): void
{ {
$controller = Kiri::getDi()->get($class);
// TODO: Implement dispatch() method. // TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/'); $path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) { if (!empty($this->version)) {
$path = '/' . trim($this->version) . $path; $path = '/' . trim($this->version) . $path;
} }
Router::addRoute(RequestMethod::REQUEST_OPTIONS, $path, [$controller, $method]); Router::addRoute(RequestMethod::REQUEST_OPTIONS, $path, [$class, $method]);
} }
+1 -3
View File
@@ -30,13 +30,11 @@ class Post extends AbstractRequestMethod implements InjectMethodInterface
public function dispatch(string $class, string $method): void public function dispatch(string $class, string $method): void
{ {
// TODO: Implement dispatch() method. // TODO: Implement dispatch() method.
$controller = Kiri::getDi()->get($class);
$path = '/' . ltrim($this->path, '/'); $path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) { if (!empty($this->version)) {
$path = '/' . trim($this->version) . $path; $path = '/' . trim($this->version) . $path;
} }
Router::addRoute(RequestMethod::REQUEST_POST, $path, [$controller, $method]); Router::addRoute(RequestMethod::REQUEST_POST, $path, [$class, $method]);
} }
+1 -2
View File
@@ -32,13 +32,12 @@ class Put extends AbstractRequestMethod implements InjectMethodInterface
*/ */
public function dispatch(string $class, string $method): void public function dispatch(string $class, string $method): void
{ {
$controller = Kiri::getDi()->get($class);
// TODO: Implement dispatch() method. // TODO: Implement dispatch() method.
$path = '/' . ltrim($this->path, '/'); $path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) { if (!empty($this->version)) {
$path = '/' . trim($this->version) . $path; $path = '/' . trim($this->version) . $path;
} }
Router::addRoute(RequestMethod::REQUEST_PUT, $path, [$controller, $method]); Router::addRoute(RequestMethod::REQUEST_PUT, $path, [$class, $method]);
} }
} }
+1 -2
View File
@@ -28,11 +28,10 @@ class Route extends AbstractRequestMethod implements InjectMethodInterface
*/ */
public function dispatch(string $class, string $method): void public function dispatch(string $class, string $method): void
{ {
$controller = \Kiri::getDi()->get($class);
$path = '/' . ltrim($this->path, '/'); $path = '/' . ltrim($this->path, '/');
if (!empty($this->version)) { if (!empty($this->version)) {
$path = '/' . trim($this->version) . $path; $path = '/' . trim($this->version) . $path;
} }
Router::addRoute([$this->method], $path, [$controller, $method]); Router::addRoute([$this->method], $path, [$class, $method]);
} }
} }