websockets: simplify JSON-RPC execution
To accommodate access to multiple protocols Moonraker will always require that the "params" field contain a dictionary, so reject any other type as invalid. There is no need to expand keyword arguments, simply pass the params dict to the callback. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
@@ -599,18 +599,16 @@ class MQTTClient(APITransport, Subscribable):
|
||||
request_method: str,
|
||||
callback: Callable[[WebRequest], Coroutine]
|
||||
) -> RPCCallback:
|
||||
async def func(**kwargs) -> Any:
|
||||
self._check_timestamp(kwargs)
|
||||
result = await callback(
|
||||
WebRequest(endpoint, kwargs, request_method))
|
||||
async def func(args: Dict[str, Any]) -> Any:
|
||||
self._check_timestamp(args)
|
||||
result = await callback(WebRequest(endpoint, args, request_method))
|
||||
return result
|
||||
return func
|
||||
|
||||
def _generate_remote_callback(self, endpoint: str) -> RPCCallback:
|
||||
async def func(**kwargs) -> Any:
|
||||
self._check_timestamp(kwargs)
|
||||
result = await self.klippy.request(
|
||||
WebRequest(endpoint, kwargs))
|
||||
async def func(args: Dict[str, Any]) -> Any:
|
||||
self._check_timestamp(args)
|
||||
result = await self.klippy.request(WebRequest(endpoint, args))
|
||||
return result
|
||||
return func
|
||||
|
||||
|
Reference in New Issue
Block a user