改名
This commit is contained in:
@@ -18,6 +18,18 @@ use Snowflake\Snowflake;
|
||||
* Interceptor constructor.
|
||||
* @param \HttpServer\IInterface\After|\HttpServer\IInterface\After[] $after
|
||||
* @throws
|
||||
* if ($object instanceof Interceptor) {
|
||||
$classes[$key] = [$object, 'Interceptor'];
|
||||
}
|
||||
if ($object instanceof Limits) {
|
||||
$classes[$key] = [$object, 'next'];
|
||||
}
|
||||
if ($object instanceof After) {
|
||||
$classes[$key] = [$object, 'onHandler'];
|
||||
}
|
||||
if ($object instanceof Middleware) {
|
||||
$classes[$key] = [$object, 'onHandler'];
|
||||
}
|
||||
*/
|
||||
public function __construct(public string|array $after)
|
||||
{
|
||||
@@ -25,7 +37,7 @@ use Snowflake\Snowflake;
|
||||
$this->after = [$this->after];
|
||||
}
|
||||
foreach ($this->after as $key => $item) {
|
||||
$this->after[$key] = Snowflake::createObject($item);
|
||||
$this->after[$key] = [Snowflake::createObject($item), 'onHandler'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ use Snowflake\Snowflake;
|
||||
$this->interceptor = [$this->interceptor];
|
||||
}
|
||||
foreach ($this->interceptor as $key => $item) {
|
||||
$this->interceptor[$key] = Snowflake::createObject($item);
|
||||
$this->interceptor[$key] = [Snowflake::createObject($item), 'Interceptor'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ use Snowflake\Snowflake;
|
||||
$this->limits = [$this->limits];
|
||||
}
|
||||
foreach ($this->limits as $key => $item) {
|
||||
$this->limits[$key] = Snowflake::createObject($item);
|
||||
$this->limits[$key] = [Snowflake::createObject($item), 'next'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ use Snowflake\Snowflake;
|
||||
$this->middleware = [$this->middleware];
|
||||
}
|
||||
foreach ($this->middleware as $key => $item) {
|
||||
$this->middleware[$key] = Snowflake::createObject($item);
|
||||
$this->middleware[$key] = [Snowflake::createObject($item), 'onHandler'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,24 +15,14 @@ use Annotation\IAnnotation;
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Route implements IAnnotation
|
||||
{
|
||||
|
||||
use \Annotation\Route\Node;
|
||||
|
||||
/**
|
||||
* Route constructor.
|
||||
* @param string $uri
|
||||
* @param string $method
|
||||
* @param array|null $middleware
|
||||
* @param array|null $interceptor
|
||||
* @param array|null $limits
|
||||
* @param array|null $after
|
||||
*/
|
||||
public function __construct(
|
||||
public string $uri,
|
||||
public string $method,
|
||||
public ?array $middleware = null,
|
||||
public ?array $interceptor = null,
|
||||
public ?array $limits = null,
|
||||
public ?array $after = null
|
||||
public string $method
|
||||
)
|
||||
{
|
||||
}
|
||||
@@ -50,9 +40,7 @@ use Annotation\IAnnotation;
|
||||
$router = Snowflake::app()->getRouter();
|
||||
// TODO: Implement setHandler() method.
|
||||
|
||||
$node = $router->addRoute($this->uri, $handler, $this->method);
|
||||
|
||||
return $this->add($node);
|
||||
return $router->addRoute($this->uri, $handler, $this->method);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,25 +25,14 @@ use Snowflake\Snowflake;
|
||||
const MESSAGE = 'MESSAGE';
|
||||
const HANDSHAKE = 'HANDSHAKE';
|
||||
|
||||
use \Annotation\Route\Node;
|
||||
|
||||
|
||||
/**
|
||||
* Socket constructor.
|
||||
* @param string $event
|
||||
* @param string|null $uri
|
||||
* @param array|null $middleware
|
||||
* @param array|null $interceptor
|
||||
* @param array|null $limits
|
||||
* @param array|null $after
|
||||
*/
|
||||
public function __construct(
|
||||
public string $event,
|
||||
public ?string $uri = null,
|
||||
public ?array $middleware = null,
|
||||
public ?array $interceptor = null,
|
||||
public ?array $limits = null,
|
||||
public ?array $after = null
|
||||
public ?string $uri = null
|
||||
)
|
||||
{
|
||||
}
|
||||
@@ -63,9 +52,7 @@ use Snowflake\Snowflake;
|
||||
|
||||
$method = $this->event . '::' . (is_null($this->uri) ? 'event' : $this->uri);
|
||||
|
||||
$node = $router->addRoute($method, $handler, 'sw::socket');
|
||||
|
||||
return $this->add($node);
|
||||
return $router->addRoute($method, $handler, 'sw::socket');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ class Middleware
|
||||
public function getGenerate(Node $node): mixed
|
||||
{
|
||||
try {
|
||||
// if (is_array($node->handler) && is_object($node->handler[0])) {
|
||||
// $this->set_attributes($node);
|
||||
// }
|
||||
if (is_array($node->handler) && is_object($node->handler[0])) {
|
||||
$this->set_attributes($node);
|
||||
}
|
||||
return $node->callback = Reduce::reduce(function () use ($node) {
|
||||
return Dispatch::create($node->handler, func_get_args())->dispatch();
|
||||
}, $this->annotation($node));
|
||||
|
||||
Reference in New Issue
Block a user