neko/internal/api/room/clipboard.go
2020-11-18 22:35:50 +01:00

32 lines
576 B
Go

package room
import (
"net/http"
"demodesk/neko/internal/utils"
)
type ClipboardPayload struct {
Text string `json:"text"`
}
func (h *RoomHandler) clipboardRead(w http.ResponseWriter, r *http.Request) {
// TODO: error check?
text := h.desktop.ReadClipboard()
utils.HttpSuccess(w, ClipboardPayload{
Text: text,
})
}
func (h *RoomHandler) clipboardWrite(w http.ResponseWriter, r *http.Request) {
data := &ClipboardPayload{}
if !utils.HttpJsonRequest(w, r, data) {
return
}
// TODO: error check?
h.desktop.WriteClipboard(data.Text)
utils.HttpSuccess(w)
}