-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hyperf\DTO\Router; | ||
|
||
use Hyperf\JsonRpc\HttpServer; | ||
use Hyperf\Rpc\Protocol; | ||
use Hyperf\RpcServer\Router\DispatcherFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
use function Hyperf\Support\make; | ||
|
||
class JsonRpcHttpRouter | ||
{ | ||
private HttpServer $server; | ||
Check failure on line 16 in src/Router/JsonRpcHttpRouter.php
|
||
|
||
private $protocol; | ||
|
||
public function __construct(ContainerInterface $container) | ||
{ | ||
$this->server = $container->get(HttpServer::class); | ||
Check failure on line 22 in src/Router/JsonRpcHttpRouter.php
|
||
} | ||
|
||
public function getRouter($serverName) | ||
{ | ||
$data = make(DispatcherFactory::class, [ | ||
Check failure on line 27 in src/Router/JsonRpcHttpRouter.php
|
||
'pathGenerator' => $this->getProtocol()->getPathGenerator(), | ||
]); | ||
return $data->getRouter($serverName); | ||
} | ||
|
||
protected function getProtocol(): Protocol | ||
Check failure on line 33 in src/Router/JsonRpcHttpRouter.php
|
||
{ | ||
$getResponseBuilder = function () { | ||
return $this->protocol; | ||
}; | ||
return $getResponseBuilder->call($this->server); | ||
} | ||
} |