diff --git a/HttpServer/Client/ClientDriver.php b/HttpServer/Client/HttpClient.php similarity index 60% rename from HttpServer/Client/ClientDriver.php rename to HttpServer/Client/HttpClient.php index 8760ad74..3b90ad7a 100644 --- a/HttpServer/Client/ClientDriver.php +++ b/HttpServer/Client/HttpClient.php @@ -5,6 +5,7 @@ namespace HttpServer\Client; use Snowflake\Abstracts\Component; +use Snowflake\Snowflake; use Swoole\Coroutine; @@ -12,14 +13,14 @@ use Swoole\Coroutine; * Class ClientDriver * @package HttpServer\Client */ -class ClientDriver extends Component +class HttpClient extends Component { /** * @param $name * @return IClient */ - public function __call($name): IClient + public static function NewRequest($name): IClient { if (Coroutine::getCid() > 0) { return Client::NewRequest(); @@ -28,4 +29,13 @@ class ClientDriver extends Component } } + + /** + * @return Http2 + */ + public static function http2() + { + return Snowflake::app()->http2; + } + } diff --git a/System/Abstracts/BaseApplication.php b/System/Abstracts/BaseApplication.php index e7c43e51..a22d588f 100644 --- a/System/Abstracts/BaseApplication.php +++ b/System/Abstracts/BaseApplication.php @@ -12,7 +12,7 @@ namespace Snowflake\Abstracts; use Exception; use HttpServer\Client\Client; -use HttpServer\Client\ClientDriver; +use HttpServer\Client\HttpClient; use HttpServer\Client\Curl; use HttpServer\Client\Http2; use HttpServer\Client\IClient; @@ -54,6 +54,7 @@ use Database\DatabasesProviders; * @property BaseGoto $goto * @property IClient $client * @property Producer $kafka + * @property Http2 $http2 */ abstract class BaseApplication extends Service { @@ -381,10 +382,11 @@ abstract class BaseApplication extends Service 'error' => ['class' => ErrorHandler::class], 'event' => ['class' => Event::class], 'annotation' => ['class' => Annotation::class], - 'client' => ['class' => ClientDriver::class], + 'client' => ['class' => HttpClient::class], 'connections' => ['class' => Connection::class], 'redis_connections' => ['class' => SRedis::class], 'pool' => ['class' => SPool::class], + 'http2' => ['class' => Http2::class], 'response' => ['class' => Response::class], 'request' => ['class' => Request::class], 'config' => ['class' => Config::class],