mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
32 lines
567 B
Go
32 lines
567 B
Go
package room
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"demodesk/neko/internal/utils"
|
|
)
|
|
|
|
type ClipboardData 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, ClipboardData{
|
|
Text: text,
|
|
})
|
|
}
|
|
|
|
func (h *RoomHandler) ClipboardWrite(w http.ResponseWriter, r *http.Request) {
|
|
data := &ClipboardData{}
|
|
if !utils.HttpJsonRequest(w, r, data) {
|
|
return
|
|
}
|
|
|
|
// TODO: error check?
|
|
h.desktop.WriteClipboard(data.Text)
|
|
utils.HttpSuccess(w)
|
|
}
|