diff --git a/HttpServer/Route/Annotation/Annotation.php b/HttpServer/Route/Annotation/Annotation.php index 8c42753e..29c4ae28 100644 --- a/HttpServer/Route/Annotation/Annotation.php +++ b/HttpServer/Route/Annotation/Annotation.php @@ -48,7 +48,6 @@ class Annotation extends \Snowflake\Annotation\Annotation * @param ReflectionClass $reflect * @param $method * @param $annotations - * @return mixed|null * @throws ReflectionException */ public function read($node, $reflect, $method, $annotations) @@ -57,26 +56,35 @@ class Annotation extends \Snowflake\Annotation\Annotation $_annotations = $this->getDocCommentAnnotation($annotations, $method->getDocComment()); - $array = []; foreach ($_annotations as $keyName => $annotation) { if (!in_array($keyName, $annotations)) { continue; } - - if ($keyName == 'Method') { - $this->bindMethod($node, $annotation); - } else if ($keyName == 'Middleware') { - $this->bindMiddleware($node, $annotation); - } else if ($keyName == 'Interceptors') { - $this->bindInterceptors($node, $annotation); - } - - $array[$keyName] = $this->pop($this->getName(...$annotation)); + $this->bind($keyName, $node, $annotation); } - return $array; } + /** + * @param $keyName + * @param $node + * @param $annotation + */ + private function bind($keyName, $node, $annotation) + { + switch ($keyName) { + case 'Method': + $this->bindMethod($node, $annotation); + break; + case 'Middleware': + $this->bindMiddleware($node, $this->pop($this->getName(...$annotation))); + break; + case'Interceptor': + $this->bindInterceptors($node, $this->pop($this->getName(...$annotation))); + break; + } + } + /** * @param $node * @param $annotation diff --git a/HttpServer/Route/Router.php b/HttpServer/Route/Router.php index 7525ea9e..62c7b459 100644 --- a/HttpServer/Route/Router.php +++ b/HttpServer/Route/Router.php @@ -468,6 +468,7 @@ class Router extends Application implements RouterInterface $annotation = $annotation->get('http'); $annotation->registration_notes($prefix . 'Interceptor', 'App\Http\Interceptor'); $annotation->registration_notes($prefix . 'Limits', 'App\Http\Limits'); + $annotation->registration_notes($prefix . 'Middleware', 'App\Http\Middleware'); $this->loadRouteDir(APP_PATH . '/routes'); }