mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
do not export REST functions.
This commit is contained in:
parent
1ae6f05c73
commit
ef03f9ec9d
@ -13,14 +13,14 @@ type BroadcastStatusPayload struct {
|
|||||||
IsActive bool `json:"is_active"`
|
IsActive bool `json:"is_active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) BroadcastStatus(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) broadcastStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
utils.HttpSuccess(w, BroadcastStatusPayload{
|
utils.HttpSuccess(w, BroadcastStatusPayload{
|
||||||
IsActive: h.capture.BroadcastEnabled(),
|
IsActive: h.capture.BroadcastEnabled(),
|
||||||
URL: h.capture.BroadcastUrl(),
|
URL: h.capture.BroadcastUrl(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) BoradcastStart(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) boradcastStart(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &BroadcastStatusPayload{}
|
data := &BroadcastStatusPayload{}
|
||||||
if !utils.HttpJsonRequest(w, r, data) {
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
return
|
return
|
||||||
@ -51,7 +51,7 @@ func (h *RoomHandler) BoradcastStart(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.HttpSuccess(w)
|
utils.HttpSuccess(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) BoradcastStop(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) boradcastStop(w http.ResponseWriter, r *http.Request) {
|
||||||
if !h.capture.BroadcastEnabled() {
|
if !h.capture.BroadcastEnabled() {
|
||||||
utils.HttpBadRequest(w, "Server is not broadcasting.")
|
utils.HttpBadRequest(w, "Server is not broadcasting.")
|
||||||
return
|
return
|
||||||
|
@ -10,7 +10,7 @@ type ClipboardPayload struct {
|
|||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) ClipboardRead(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) clipboardRead(w http.ResponseWriter, r *http.Request) {
|
||||||
// TODO: error check?
|
// TODO: error check?
|
||||||
text := h.desktop.ReadClipboard()
|
text := h.desktop.ReadClipboard()
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ func (h *RoomHandler) ClipboardRead(w http.ResponseWriter, r *http.Request) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) ClipboardWrite(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) clipboardWrite(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &ClipboardPayload{}
|
data := &ClipboardPayload{}
|
||||||
if !utils.HttpJsonRequest(w, r, data) {
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
return
|
return
|
||||||
|
@ -13,7 +13,7 @@ type ControlGivePayload struct {
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) ControlRequest(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) controlRequest(w http.ResponseWriter, r *http.Request) {
|
||||||
session := auth.GetSession(r)
|
session := auth.GetSession(r)
|
||||||
if session.IsHost() {
|
if session.IsHost() {
|
||||||
utils.HttpBadRequest(w, "User is already host.")
|
utils.HttpBadRequest(w, "User is already host.")
|
||||||
@ -37,7 +37,7 @@ func (h *RoomHandler) ControlRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.HttpSuccess(w)
|
utils.HttpSuccess(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) ControlRelease(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) controlRelease(w http.ResponseWriter, r *http.Request) {
|
||||||
session := auth.GetSession(r)
|
session := auth.GetSession(r)
|
||||||
if !session.IsHost() {
|
if !session.IsHost() {
|
||||||
utils.HttpBadRequest(w, "User is not the host.")
|
utils.HttpBadRequest(w, "User is not the host.")
|
||||||
@ -55,7 +55,7 @@ func (h *RoomHandler) ControlRelease(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.HttpSuccess(w)
|
utils.HttpSuccess(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) ControlTake(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) controlTake(w http.ResponseWriter, r *http.Request) {
|
||||||
session := auth.GetSession(r)
|
session := auth.GetSession(r)
|
||||||
|
|
||||||
h.sessions.SetHost(session)
|
h.sessions.SetHost(session)
|
||||||
@ -69,7 +69,7 @@ func (h *RoomHandler) ControlTake(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.HttpSuccess(w)
|
utils.HttpSuccess(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) ControlGive(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) controlGive(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &ControlGivePayload{}
|
data := &ControlGivePayload{}
|
||||||
if !utils.HttpJsonRequest(w, r, data) {
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
return
|
return
|
||||||
|
@ -36,33 +36,33 @@ func New(
|
|||||||
|
|
||||||
func (h *RoomHandler) Route(r chi.Router) {
|
func (h *RoomHandler) Route(r chi.Router) {
|
||||||
r.With(auth.AdminsOnly).Route("/broadcast", func(r chi.Router) {
|
r.With(auth.AdminsOnly).Route("/broadcast", func(r chi.Router) {
|
||||||
r.Get("/", h.BroadcastStatus)
|
r.Get("/", h.broadcastStatus)
|
||||||
r.Post("/start", h.BoradcastStart)
|
r.Post("/start", h.boradcastStart)
|
||||||
r.Post("/stop", h.BoradcastStop)
|
r.Post("/stop", h.boradcastStop)
|
||||||
})
|
})
|
||||||
|
|
||||||
r.With(auth.HostsOnly).Route("/clipboard", func(r chi.Router) {
|
r.With(auth.HostsOnly).Route("/clipboard", func(r chi.Router) {
|
||||||
r.Get("/", h.ClipboardRead)
|
r.Get("/", h.clipboardRead)
|
||||||
r.Post("/", h.ClipboardWrite)
|
r.Post("/", h.clipboardWrite)
|
||||||
})
|
})
|
||||||
|
|
||||||
r.With(auth.HostsOnly).Route("/keyboard", func(r chi.Router) {
|
r.With(auth.HostsOnly).Route("/keyboard", func(r chi.Router) {
|
||||||
r.Post("/layout", h.KeyboardLayoutSet)
|
r.Post("/layout", h.keyboardLayoutSet)
|
||||||
r.Post("/modifiers", h.KeyboardModifiersSet)
|
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)
|
||||||
|
|
||||||
r.With(auth.AdminsOnly).Post("/take", h.ControlTake)
|
r.With(auth.AdminsOnly).Post("/take", h.controlTake)
|
||||||
r.With(auth.AdminsOnly).Post("/give", h.ControlGive)
|
r.With(auth.AdminsOnly).Post("/give", h.controlGive)
|
||||||
})
|
})
|
||||||
|
|
||||||
r.Route("/screen", func(r chi.Router) {
|
r.Route("/screen", func(r chi.Router) {
|
||||||
r.Get("/", h.ScreenConfiguration)
|
r.Get("/", h.screenConfiguration)
|
||||||
|
|
||||||
r.With(auth.AdminsOnly).Post("/", h.ScreenConfigurationChange)
|
r.With(auth.AdminsOnly).Post("/", h.screenConfigurationChange)
|
||||||
r.With(auth.AdminsOnly).Get("/configurations", h.ScreenConfigurationsList)
|
r.With(auth.AdminsOnly).Get("/configurations", h.screenConfigurationsList)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ type KeyboardModifiersData struct {
|
|||||||
ScrollLock *bool `json:"scrollock"`
|
ScrollLock *bool `json:"scrollock"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) KeyboardLayoutSet(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) keyboardLayoutSet(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &KeyboardLayoutData{}
|
data := &KeyboardLayoutData{}
|
||||||
if !utils.HttpJsonRequest(w, r, data) {
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
return
|
return
|
||||||
@ -27,7 +27,7 @@ func (h *RoomHandler) KeyboardLayoutSet(w http.ResponseWriter, r *http.Request)
|
|||||||
utils.HttpSuccess(w)
|
utils.HttpSuccess(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) KeyboardModifiersSet(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) keyboardModifiersSet(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &KeyboardModifiersData{}
|
data := &KeyboardModifiersData{}
|
||||||
if !utils.HttpJsonRequest(w, r, data) {
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
return
|
return
|
||||||
|
@ -15,7 +15,7 @@ type ScreenConfigurationPayload struct {
|
|||||||
Rate int `json:"rate"`
|
Rate int `json:"rate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) ScreenConfiguration(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) screenConfiguration(w http.ResponseWriter, r *http.Request) {
|
||||||
size := h.desktop.GetScreenSize()
|
size := h.desktop.GetScreenSize()
|
||||||
|
|
||||||
if size == nil {
|
if size == nil {
|
||||||
@ -30,7 +30,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 := &ScreenConfigurationPayload{}
|
data := &ScreenConfigurationPayload{}
|
||||||
if !utils.HttpJsonRequest(w, r, data) {
|
if !utils.HttpJsonRequest(w, r, data) {
|
||||||
return
|
return
|
||||||
@ -55,7 +55,7 @@ func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.R
|
|||||||
utils.HttpSuccess(w, data)
|
utils.HttpSuccess(w, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) ScreenConfigurationsList(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) screenConfigurationsList(w http.ResponseWriter, r *http.Request) {
|
||||||
list := []ScreenConfigurationPayload{}
|
list := []ScreenConfigurationPayload{}
|
||||||
|
|
||||||
ScreenConfigurations := h.desktop.ScreenConfigurations()
|
ScreenConfigurations := h.desktop.ScreenConfigurations()
|
||||||
|
Loading…
Reference in New Issue
Block a user