client load all config
This commit is contained in:
parent
d67bb4aefe
commit
2c96596e57
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user