add rpc server no config exception
This commit is contained in:
parent
6838c279a2
commit
420725e262
|
@ -12,16 +12,14 @@ class ClientServiceProvider extends ServiceProvider
|
|||
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
* @throws RpcServerException
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->configure('rpc');
|
||||
$config = config('rpc');
|
||||
if (!is_array($config)) {
|
||||
throw new RpcServerException("Application's Rpc Config Undefind", 500);
|
||||
throw new RpcServerException("Application's Rpc Client Config Undefind", 500);
|
||||
}
|
||||
$this->app->singleton('rpc', function () use ($config) {
|
||||
return new Client($config);
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace JsonRpc\Providers;
|
|||
|
||||
use App\Http\Middleware\JsonRpc;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use JsonRpc\Exception\RpcServerException;
|
||||
use JsonRpc\Middleware\Security;
|
||||
use JsonRpc\Server\JsonRpcDoc;
|
||||
use JsonRpc\Server\JsonRpcServer;
|
||||
|
@ -33,7 +34,9 @@ class LumenServerServiceProvider extends ServiceProvider
|
|||
|
||||
$this->app->configure('rpc');
|
||||
$config = config('rpc.server');
|
||||
|
||||
if (!is_array($config)) {
|
||||
throw new RpcServerException("Application's Rpc Server Config Undefind", 500);
|
||||
}
|
||||
$callback = function () use ($config) {
|
||||
$server = new JsonRpcServer($config);
|
||||
return $server->handler();
|
||||
|
|
Loading…
Reference in New Issue
Block a user