From d47302e2cd013013472df91522ef0973256642d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Fri, 3 May 2024 22:41:42 +0200 Subject: [PATCH] remo superfluous structs from keyboard api. --- internal/api/room/keyboard.go | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/internal/api/room/keyboard.go b/internal/api/room/keyboard.go index a8115c08..f3765f56 100644 --- a/internal/api/room/keyboard.go +++ b/internal/api/room/keyboard.go @@ -7,21 +7,13 @@ import ( "github.com/demodesk/neko/pkg/utils" ) -type KeyboardMapData struct { - types.KeyboardMap -} - -type KeyboardModifiersData struct { - types.KeyboardModifiers -} - func (h *RoomHandler) keyboardMapSet(w http.ResponseWriter, r *http.Request) error { - data := &KeyboardMapData{} - if err := utils.HttpJsonRequest(w, r, data); err != nil { + keyboardMap := types.KeyboardMap{} + if err := utils.HttpJsonRequest(w, r, &keyboardMap); err != nil { return err } - err := h.desktop.SetKeyboardMap(data.KeyboardMap) + err := h.desktop.SetKeyboardMap(keyboardMap) if err != nil { return utils.HttpInternalServerError().WithInternalErr(err) } @@ -30,28 +22,26 @@ func (h *RoomHandler) keyboardMapSet(w http.ResponseWriter, r *http.Request) err } func (h *RoomHandler) keyboardMapGet(w http.ResponseWriter, r *http.Request) error { - data, err := h.desktop.GetKeyboardMap() + keyboardMap, err := h.desktop.GetKeyboardMap() if err != nil { return utils.HttpInternalServerError().WithInternalErr(err) } - return utils.HttpSuccess(w, KeyboardMapData{ - KeyboardMap: *data, - }) + return utils.HttpSuccess(w, keyboardMap) } func (h *RoomHandler) keyboardModifiersSet(w http.ResponseWriter, r *http.Request) error { - data := &KeyboardModifiersData{} - if err := utils.HttpJsonRequest(w, r, data); err != nil { + keyboardModifiers := types.KeyboardModifiers{} + if err := utils.HttpJsonRequest(w, r, &keyboardModifiers); err != nil { return err } - h.desktop.SetKeyboardModifiers(data.KeyboardModifiers) + h.desktop.SetKeyboardModifiers(keyboardModifiers) return utils.HttpSuccess(w) } func (h *RoomHandler) keyboardModifiersGet(w http.ResponseWriter, r *http.Request) error { - return utils.HttpSuccess(w, KeyboardModifiersData{ - KeyboardModifiers: h.desktop.GetKeyboardModifiers(), - }) + keyboardModifiers := h.desktop.GetKeyboardModifiers() + + return utils.HttpSuccess(w, keyboardModifiers) }