mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
32 lines
576 B
Go
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)
|
|
}
|