diff --git a/internal/api/room/clipboard.go b/internal/api/room/clipboard.go index 37259fe1..0396d9c5 100644 --- a/internal/api/room/clipboard.go +++ b/internal/api/room/clipboard.go @@ -6,7 +6,7 @@ import ( "demodesk/neko/internal/utils" ) -type ClipboardData struct { +type ClipboardPayload struct { Text string `json:"text"` } @@ -14,13 +14,13 @@ func (h *RoomHandler) ClipboardRead(w http.ResponseWriter, r *http.Request) { // TODO: error check? text := h.desktop.ReadClipboard() - utils.HttpSuccess(w, ClipboardData{ + utils.HttpSuccess(w, ClipboardPayload{ Text: text, }) } func (h *RoomHandler) ClipboardWrite(w http.ResponseWriter, r *http.Request) { - data := &ClipboardData{} + data := &ClipboardPayload{} if !utils.HttpJsonRequest(w, r, data) { return } diff --git a/internal/api/room/handler.go b/internal/api/room/handler.go index 18e2b849..fa202188 100644 --- a/internal/api/room/handler.go +++ b/internal/api/room/handler.go @@ -35,11 +35,10 @@ func New( } func (h *RoomHandler) Route(r chi.Router) { - r.Route("/screen", func(r chi.Router) { - r.Get("/", h.ScreenConfiguration) - - r.With(auth.AdminsOnly).Post("/", h.ScreenConfigurationChange) - r.With(auth.AdminsOnly).Get("/configurations", h.ScreenConfigurationsList) + r.With(auth.AdminsOnly).Route("/broadcast", func(r chi.Router) { + r.Get("/", h.BroadcastStatus) + r.Post("/start", h.BoradcastStart) + r.Post("/stop", h.BoradcastStop) }) r.With(auth.HostsOnly).Route("/clipboard", func(r chi.Router) { @@ -47,6 +46,11 @@ func (h *RoomHandler) Route(r chi.Router) { r.Post("/", h.ClipboardWrite) }) + r.With(auth.HostsOnly).Route("/keyboard", func(r chi.Router) { + r.Post("/layout", h.KeyboardLayoutSet) + r.Post("/modifiers", h.KeyboardModifiersSet) + }) + r.Route("/control", func(r chi.Router) { r.Post("/request", h.ControlRequest) r.Post("/release", h.ControlRelease) @@ -55,14 +59,10 @@ func (h *RoomHandler) Route(r chi.Router) { r.With(auth.AdminsOnly).Post("/give", h.ControlGive) }) - r.With(auth.AdminsOnly).Route("/broadcast", func(r chi.Router) { - r.Get("/", h.BroadcastStatus) - r.Post("/start", h.BoradcastStart) - r.Post("/stop", h.BoradcastStop) - }) + r.Route("/screen", func(r chi.Router) { + r.Get("/", h.ScreenConfiguration) - r.With(auth.HostsOnly).Route("/keyboard", func(r chi.Router) { - r.Post("/layout", h.KeyboardLayoutSet) - r.Post("/modifiers", h.KeyboardModifiersSet) + r.With(auth.AdminsOnly).Post("/", h.ScreenConfigurationChange) + r.With(auth.AdminsOnly).Get("/configurations", h.ScreenConfigurationsList) }) } diff --git a/internal/api/room/screen.go b/internal/api/room/screen.go index 30351dd6..a54fd4eb 100644 --- a/internal/api/room/screen.go +++ b/internal/api/room/screen.go @@ -9,7 +9,7 @@ import ( "demodesk/neko/internal/http/auth" ) -type ScreenConfiguration struct { +type ScreenConfigurationPayload struct { Width int `json:"width"` Height int `json:"height"` Rate int `json:"rate"` @@ -23,7 +23,7 @@ func (h *RoomHandler) ScreenConfiguration(w http.ResponseWriter, r *http.Request return } - utils.HttpSuccess(w, ScreenConfiguration{ + utils.HttpSuccess(w, ScreenConfigurationPayload{ Width: size.Width, Height: size.Height, Rate: int(size.Rate), @@ -31,7 +31,7 @@ func (h *RoomHandler) ScreenConfiguration(w http.ResponseWriter, r *http.Request } func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.Request) { - data := &ScreenConfiguration{} + data := &ScreenConfigurationPayload{} if !utils.HttpJsonRequest(w, r, data) { return } @@ -56,12 +56,12 @@ func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.R } func (h *RoomHandler) ScreenConfigurationsList(w http.ResponseWriter, r *http.Request) { - list := []ScreenConfiguration{} + list := []ScreenConfigurationPayload{} ScreenConfigurations := h.desktop.ScreenConfigurations() for _, size := range ScreenConfigurations { for _, fps := range size.Rates { - list = append(list, ScreenConfiguration{ + list = append(list, ScreenConfigurationPayload{ Width: size.Width, Height: size.Height, Rate: int(fps),