From 6c86f1f2e5c11995116ee368c619e8f5324015b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 25 Apr 2023 17:22:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Annotate/Delete.php | 2 +- src/Annotate/Get.php | 2 +- src/Annotate/Head.php | 2 +- src/Annotate/Options.php | 2 +- src/Annotate/Post.php | 2 +- src/Annotate/Put.php | 2 +- src/Annotate/Route.php | 2 +- src/Request.php | 11 +++++++++++ 8 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Annotate/Delete.php b/src/Annotate/Delete.php index f61e4da..a7a97ff 100644 --- a/src/Annotate/Delete.php +++ b/src/Annotate/Delete.php @@ -33,7 +33,7 @@ class Delete extends AbstractRequestMethod implements InjectRouteInterface public function dispatch(object $class, string $method): void { // TODO: Implement dispatch() method. - $path = $this->version . '/' . ltrim($this->path, '/'); + $path = '/' . ltrim($this->path, '/'); Router::addRoute(RequestMethod::REQUEST_DELETE, $path, [$class, $method]); } diff --git a/src/Annotate/Get.php b/src/Annotate/Get.php index 48b4ff2..afad291 100644 --- a/src/Annotate/Get.php +++ b/src/Annotate/Get.php @@ -33,7 +33,7 @@ class Get extends AbstractRequestMethod implements InjectRouteInterface public function dispatch(object $class, string $method): void { // TODO: Implement dispatch() method. - $path = $this->version . '/' . ltrim($this->path, '/'); + $path = '/' . ltrim($this->path, '/'); Router::addRoute(RequestMethod::REQUEST_GET, $path, [$class, $method]); } diff --git a/src/Annotate/Head.php b/src/Annotate/Head.php index bc653ba..a8299a7 100644 --- a/src/Annotate/Head.php +++ b/src/Annotate/Head.php @@ -34,7 +34,7 @@ class Head extends AbstractRequestMethod implements InjectRouteInterface public function dispatch(object $class, string $method): void { // TODO: Implement dispatch() method. - $path = $this->version . '/' . ltrim($this->path, '/'); + $path = '/' . ltrim($this->path, '/'); Router::addRoute(RequestMethod::REQUEST_HEAD, $path, [$class, $method]); } diff --git a/src/Annotate/Options.php b/src/Annotate/Options.php index 903efeb..b19f774 100644 --- a/src/Annotate/Options.php +++ b/src/Annotate/Options.php @@ -34,7 +34,7 @@ class Options extends AbstractRequestMethod implements InjectRouteInterface public function dispatch(object $class, string $method): void { // TODO: Implement dispatch() method. - $path = $this->version . '/' . ltrim($this->path, '/'); + $path = '/' . ltrim($this->path, '/'); Router::addRoute(RequestMethod::REQUEST_OPTIONS, $path, [$class, $method]); } diff --git a/src/Annotate/Post.php b/src/Annotate/Post.php index bb059e4..31bd9e3 100644 --- a/src/Annotate/Post.php +++ b/src/Annotate/Post.php @@ -33,7 +33,7 @@ class Post extends AbstractRequestMethod implements InjectRouteInterface public function dispatch(object $class, string $method): void { // TODO: Implement dispatch() method. - $path = $this->version . '/' . ltrim($this->path, '/'); + $path = '/' . ltrim($this->path, '/'); Router::addRoute(RequestMethod::REQUEST_POST, $path, [$class, $method]); } diff --git a/src/Annotate/Put.php b/src/Annotate/Put.php index 4bf5360..691aedf 100644 --- a/src/Annotate/Put.php +++ b/src/Annotate/Put.php @@ -34,7 +34,7 @@ class Put extends AbstractRequestMethod implements InjectRouteInterface public function dispatch(object $class, string $method): void { // TODO: Implement dispatch() method. - $path = $this->version . '/' . ltrim($this->path, '/'); + $path = '/' . ltrim($this->path, '/'); Router::addRoute(RequestMethod::REQUEST_PUT, $path, [$class, $method]); } diff --git a/src/Annotate/Route.php b/src/Annotate/Route.php index efac4fa..4e4b940 100644 --- a/src/Annotate/Route.php +++ b/src/Annotate/Route.php @@ -30,7 +30,7 @@ class Route extends AbstractRequestMethod implements InjectRouteInterface public function dispatch(object $class, string $method): void { // TODO: Implement dispatch() method. - $path = $this->version . '/' . ltrim($this->path, '/'); + $path = '/' . ltrim($this->path, '/'); Router::addRoute([$this->method], $path, [$class, $method]); } diff --git a/src/Request.php b/src/Request.php index 3bbf1d2..cbd92e3 100644 --- a/src/Request.php +++ b/src/Request.php @@ -65,6 +65,17 @@ class Request implements ServerRequestInterface } + /** + * @param string $name + * @return mixed + */ + public function __get(string $name): mixed + { + // TODO: Implement __get() method. + return $this->__call__('get' . ucfirst($name)); + } + + /** * Retrieves the HTTP protocol version as a string. *