改名
This commit is contained in:
@@ -545,21 +545,17 @@ class Router extends HttpService implements RouterInterface
|
||||
*/
|
||||
public function find_path(Request $request): ?Node
|
||||
{
|
||||
// return $this->Branch_search($request);
|
||||
$method = $request->getMethod();
|
||||
$uri = $request->headers->get('request_uri', '/');
|
||||
|
||||
if (!isset(static::$nodes[$method])) {
|
||||
return null;
|
||||
}
|
||||
$methods = static::$nodes[$method];
|
||||
if (isset($methods[$uri])) {
|
||||
$methods = static::$nodes[$method][$uri] ?? null;
|
||||
if (!is_null($methods[$uri])) {
|
||||
return $methods[$uri];
|
||||
}
|
||||
if (!$request->isOption || !isset($methods['/'])) {
|
||||
return null;
|
||||
if ($request->isOption) {
|
||||
return static::$nodes[$method]['*'] ?? null;
|
||||
}
|
||||
return $methods['/'];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -92,11 +92,14 @@ class Server extends HttpService
|
||||
*/
|
||||
private function rpcListener($rpcService)
|
||||
{
|
||||
$rpcService['events'][Constant::CONNECT] = [Service::class, 'onConnect'];
|
||||
$rpcService['events'][Constant::DISCONNECT] = [Service::class, 'onClose'];
|
||||
$rpcService['events'][Constant::CLOSE] = [Service::class, 'onClose'];
|
||||
$rpcService['events'][Constant::RECEIVE] = [Service::class, 'onReceive'];
|
||||
$rpcService['events'][Constant::PACKET] = [Service::class, 'onPacket'];
|
||||
if (in_array($rpcService['mode'], [SWOOLE_SOCK_UDP, SWOOLE_UDP, SWOOLE_UDP6, SWOOLE_SOCK_UDP6])) {
|
||||
$rpcService['events'][Constant::PACKET] = [Service::class, 'onPacket'];
|
||||
} else {
|
||||
$rpcService['events'][Constant::RECEIVE] = [Service::class, 'onReceive'];
|
||||
$rpcService['events'][Constant::CONNECT] = [Service::class, 'onConnect'];
|
||||
$rpcService['events'][Constant::DISCONNECT] = [Service::class, 'onDisconnect'];
|
||||
$rpcService['events'][Constant::CLOSE] = [Service::class, 'onClose'];
|
||||
}
|
||||
$this->manager->addListener($rpcService['type'], $rpcService['host'], $rpcService['port'], $rpcService['mode'], $rpcService);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user