diff options
author | Devaev Maxim <[email protected]> | 2020-12-25 08:35:02 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-12-25 08:35:02 +0300 |
commit | 4447e49abb518a4da83d6adc16ca1bb5dcba5fae (patch) | |
tree | 3edc747b961f278de277ac794783ae2a264ba270 /kvmd/apps | |
parent | 08fc4130440001c69151884e12db1b3fb259971f (diff) |
api refactoring
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/kvmd/api/hid.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/kvmd/apps/kvmd/api/hid.py b/kvmd/apps/kvmd/api/hid.py index 9c39ab20..8e667b79 100644 --- a/kvmd/apps/kvmd/api/hid.py +++ b/kvmd/apps/kvmd/api/hid.py @@ -69,14 +69,17 @@ class HidApi: async def __state_handler(self, _: Request) -> Response: return make_json_response(await self.__hid.get_state()) - @exposed_http("POST", "/hid/keyboard/set_params") - async def __keyboard_set_params_handler(self, request: Request) -> Response: - self.__hid.set_keyboard_output(valid_hid_keyboard_output(request.query.get("output"))) - return make_json_response() - - @exposed_http("POST", "/hid/mouse/set_params") - async def __mouse_set_params_handler(self, request: Request) -> Response: - self.__hid.set_mouse_output(valid_hid_mouse_output(request.query.get("output"))) + @exposed_http("POST", "/hid/set_params") + async def __set_params_handler(self, request: Request) -> Response: + params = { + key: validator(request.query.get(key)) + for (key, validator) in [ + ("keyboard_output", valid_hid_keyboard_output), + ("mouse_output", valid_hid_mouse_output), + ] + if request.query.get(key) is not None + } + await self.__hid.set_params(**params) # type: ignore return make_json_response() @exposed_http("POST", "/hid/set_connected") |