From 2c96596e57ae6db337407a12961e056dcc4fdac1 Mon Sep 17 00:00:00 2001 From: dongwei <838456736@qq.com> Date: Fri, 11 Jan 2019 18:17:52 +0800 Subject: [PATCH] client load all config --- src/Client.php | 7 +++++-- src/Providers/ClientServiceProvider.php | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Client.php b/src/Client.php index 77c730e..52d8fc2 100644 --- a/src/Client.php +++ b/src/Client.php @@ -31,6 +31,10 @@ class Client */ protected $http; + /** + * which server rpc call choose + * @var array + */ protected $server_config; public function __construct($config) @@ -56,7 +60,7 @@ class Client */ public function endpoint($k) { - $this->server_config = $this->config[$k]; + $this->server_config = $this->config['client'][$k]; $default = [ 'app' => $k, @@ -106,7 +110,6 @@ class Client try { $headers = [ 'client_app' => $this->config['app'], - 'server_app' => $this->server_config['app'] ]; $resp = $this->http->request('POST', 'rpc/json-rpc-v2.json', [ 'headers' => $headers, diff --git a/src/Providers/ClientServiceProvider.php b/src/Providers/ClientServiceProvider.php index 0c58e3b..3acac7e 100644 --- a/src/Providers/ClientServiceProvider.php +++ b/src/Providers/ClientServiceProvider.php @@ -18,13 +18,13 @@ class ClientServiceProvider extends ServiceProvider public function register() { $this->app->configure('rpc'); - $config = config('rpc.client'); + $config = config('rpc'); $this->app->singleton('rpc', function () use ($config) { return new Client($config); }); - foreach ($config as $k => $item) { + foreach ($config['client'] as $k => $item) { $this->app->singleton('rpc.' . $k, function () use ($k) { return app('rpc')->endpoint($k); });