remo superfluous structs from keyboard api.

This commit is contained in:
Miroslav Šedivý 2024-05-03 22:41:42 +02:00
parent b90eb87c22
commit d47302e2cd

View File

@ -7,21 +7,13 @@ import (
"github.com/demodesk/neko/pkg/utils" "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 { func (h *RoomHandler) keyboardMapSet(w http.ResponseWriter, r *http.Request) error {
data := &KeyboardMapData{} keyboardMap := types.KeyboardMap{}
if err := utils.HttpJsonRequest(w, r, data); err != nil { if err := utils.HttpJsonRequest(w, r, &keyboardMap); err != nil {
return err return err
} }
err := h.desktop.SetKeyboardMap(data.KeyboardMap) err := h.desktop.SetKeyboardMap(keyboardMap)
if err != nil { if err != nil {
return utils.HttpInternalServerError().WithInternalErr(err) 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 { func (h *RoomHandler) keyboardMapGet(w http.ResponseWriter, r *http.Request) error {
data, err := h.desktop.GetKeyboardMap() keyboardMap, err := h.desktop.GetKeyboardMap()
if err != nil { if err != nil {
return utils.HttpInternalServerError().WithInternalErr(err) return utils.HttpInternalServerError().WithInternalErr(err)
} }
return utils.HttpSuccess(w, KeyboardMapData{ return utils.HttpSuccess(w, keyboardMap)
KeyboardMap: *data,
})
} }
func (h *RoomHandler) keyboardModifiersSet(w http.ResponseWriter, r *http.Request) error { func (h *RoomHandler) keyboardModifiersSet(w http.ResponseWriter, r *http.Request) error {
data := &KeyboardModifiersData{} keyboardModifiers := types.KeyboardModifiers{}
if err := utils.HttpJsonRequest(w, r, data); err != nil { if err := utils.HttpJsonRequest(w, r, &keyboardModifiers); err != nil {
return err return err
} }
h.desktop.SetKeyboardModifiers(data.KeyboardModifiers) h.desktop.SetKeyboardModifiers(keyboardModifiers)
return utils.HttpSuccess(w) return utils.HttpSuccess(w)
} }
func (h *RoomHandler) keyboardModifiersGet(w http.ResponseWriter, r *http.Request) error { 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)
} }