mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
Data -> Payload & change order.
This commit is contained in:
parent
ac2fc100b4
commit
18ca647c76
@ -6,7 +6,7 @@ import (
|
|||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClipboardData struct {
|
type ClipboardPayload struct {
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,13 +14,13 @@ func (h *RoomHandler) ClipboardRead(w http.ResponseWriter, r *http.Request) {
|
|||||||
// TODO: error check?
|
// TODO: error check?
|
||||||
text := h.desktop.ReadClipboard()
|
text := h.desktop.ReadClipboard()
|
||||||
|
|
||||||
utils.HttpSuccess(w, ClipboardData{
|
utils.HttpSuccess(w, ClipboardPayload{
|
||||||
Text: text,
|
Text: text,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) ClipboardWrite(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) ClipboardWrite(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &ClipboardData{}
|
data := &ClipboardPayload{}
|
||||||
if !utils.HttpJsonRequest(w, r, data) {
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,10 @@ func New(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) Route(r chi.Router) {
|
func (h *RoomHandler) Route(r chi.Router) {
|
||||||
r.Route("/screen", func(r chi.Router) {
|
r.With(auth.AdminsOnly).Route("/broadcast", func(r chi.Router) {
|
||||||
r.Get("/", h.ScreenConfiguration)
|
r.Get("/", h.BroadcastStatus)
|
||||||
|
r.Post("/start", h.BoradcastStart)
|
||||||
r.With(auth.AdminsOnly).Post("/", h.ScreenConfigurationChange)
|
r.Post("/stop", h.BoradcastStop)
|
||||||
r.With(auth.AdminsOnly).Get("/configurations", h.ScreenConfigurationsList)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
r.With(auth.HostsOnly).Route("/clipboard", func(r chi.Router) {
|
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.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.Route("/control", func(r chi.Router) {
|
||||||
r.Post("/request", h.ControlRequest)
|
r.Post("/request", h.ControlRequest)
|
||||||
r.Post("/release", h.ControlRelease)
|
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).Post("/give", h.ControlGive)
|
||||||
})
|
})
|
||||||
|
|
||||||
r.With(auth.AdminsOnly).Route("/broadcast", func(r chi.Router) {
|
r.Route("/screen", func(r chi.Router) {
|
||||||
r.Get("/", h.BroadcastStatus)
|
r.Get("/", h.ScreenConfiguration)
|
||||||
r.Post("/start", h.BoradcastStart)
|
|
||||||
r.Post("/stop", h.BoradcastStop)
|
|
||||||
})
|
|
||||||
|
|
||||||
r.With(auth.HostsOnly).Route("/keyboard", func(r chi.Router) {
|
r.With(auth.AdminsOnly).Post("/", h.ScreenConfigurationChange)
|
||||||
r.Post("/layout", h.KeyboardLayoutSet)
|
r.With(auth.AdminsOnly).Get("/configurations", h.ScreenConfigurationsList)
|
||||||
r.Post("/modifiers", h.KeyboardModifiersSet)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"demodesk/neko/internal/http/auth"
|
"demodesk/neko/internal/http/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScreenConfiguration struct {
|
type ScreenConfigurationPayload struct {
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
Height int `json:"height"`
|
Height int `json:"height"`
|
||||||
Rate int `json:"rate"`
|
Rate int `json:"rate"`
|
||||||
@ -23,7 +23,7 @@ func (h *RoomHandler) ScreenConfiguration(w http.ResponseWriter, r *http.Request
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.HttpSuccess(w, ScreenConfiguration{
|
utils.HttpSuccess(w, ScreenConfigurationPayload{
|
||||||
Width: size.Width,
|
Width: size.Width,
|
||||||
Height: size.Height,
|
Height: size.Height,
|
||||||
Rate: int(size.Rate),
|
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) {
|
func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &ScreenConfiguration{}
|
data := &ScreenConfigurationPayload{}
|
||||||
if !utils.HttpJsonRequest(w, r, data) {
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
return
|
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) {
|
func (h *RoomHandler) ScreenConfigurationsList(w http.ResponseWriter, r *http.Request) {
|
||||||
list := []ScreenConfiguration{}
|
list := []ScreenConfigurationPayload{}
|
||||||
|
|
||||||
ScreenConfigurations := h.desktop.ScreenConfigurations()
|
ScreenConfigurations := h.desktop.ScreenConfigurations()
|
||||||
for _, size := range ScreenConfigurations {
|
for _, size := range ScreenConfigurations {
|
||||||
for _, fps := range size.Rates {
|
for _, fps := range size.Rates {
|
||||||
list = append(list, ScreenConfiguration{
|
list = append(list, ScreenConfigurationPayload{
|
||||||
Width: size.Width,
|
Width: size.Width,
|
||||||
Height: size.Height,
|
Height: size.Height,
|
||||||
Rate: int(fps),
|
Rate: int(fps),
|
||||||
|
Loading…
Reference in New Issue
Block a user