From fe2105be26d5b1fe6221c9e1d34e087ea709ed70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 31 Aug 2020 23:27:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/Annotation/Annotation.php | 2 +- system/Annotation/Definition/Http.php | 50 ++++++--------------------- 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/system/Annotation/Annotation.php b/system/Annotation/Annotation.php index f03d8407..912c6626 100644 --- a/system/Annotation/Annotation.php +++ b/system/Annotation/Annotation.php @@ -43,7 +43,7 @@ class Annotation extends BaseAnnotation private $_classMap = [ 'websocket' => Websocket::class, - 'http' => \HttpServer\Events\Http::class + 'http' => Http::class ]; diff --git a/system/Annotation/Definition/Http.php b/system/Annotation/Definition/Http.php index ac21ba11..89f924e4 100644 --- a/system/Annotation/Definition/Http.php +++ b/system/Annotation/Definition/Http.php @@ -20,55 +20,26 @@ class Http extends Annotation /** * @var string - * 拦截器 + * @Interceptor(LoginInterceptor) */ - private $Interceptor; + private $Interceptor = 'required|not empty'; /** * @var string - * 限速 */ - private $Limits; + private $Limits = 'required|not empty'; + + protected $_annotations = []; /** - * @param $controller - * @param $methodName - * @param $handler - * @return array - * @throws ReflectionException + * @param $events + * @return bool */ - public function createLimits($controller, $methodName, $handler) + public function isLegitimate($events) { - $namespace = 'App\Http\Interceptor\\' . $handler; - $class = Snowflake::getDi()->getReflect($namespace); - - $object = $class->newInstance(); - - - $method = $class->getMethod('Interceptor'); - - - return [$object, 'Interceptor']; - } - - - /** - * @param $controller - * @param $methodName - * @param $handler - * @return array - * @throws ReflectionException - */ - public function createInterceptor($controller, $methodName, $handler) - { - $namespace = 'App\Interceptor\\' . $handler; - $class = Snowflake::getDi()->getReflect($namespace); - - $object = $class->newInstance(); - - return [$object, 'Interceptor', [request(), [$controller, $methodName]]]; + return isset($events[2]) && !empty($events[2]); } @@ -79,7 +50,8 @@ class Http extends Annotation */ public function getName($name, $events) { - return self::HTTP_EVENT . $name . ':' . $events[1]; + return self::HTTP_EVENT . $name . ':' . $events[2]; } + }