implement file drop API.

This commit is contained in:
Miroslav Šedivý
2021-01-06 18:57:50 +01:00
parent 64187964d4
commit 62ba53dc46
4 changed files with 54 additions and 0 deletions

23
internal/api/room/drop.go Normal file
View File

@ -0,0 +1,23 @@
package room
import (
"net/http"
"demodesk/neko/internal/utils"
)
type DropPayload struct {
X int `json:"x"`
Y int `json:"y"`
Files []string `json:"files"`
}
func (h *RoomHandler) dropFiles(w http.ResponseWriter, r *http.Request) {
data := &DropPayload{}
if !utils.HttpJsonRequest(w, r, data) {
return
}
h.desktop.DropFiles(data.X, data.Y, data.Files)
utils.HttpSuccess(w)
}

View File

@ -60,4 +60,8 @@ func (h *RoomHandler) Route(r chi.Router) {
r.With(auth.AdminsOnly).Post("/", h.screenConfigurationChange)
r.With(auth.AdminsOnly).Get("/configurations", h.screenConfigurationsList)
})
r.Route("/drop", func(r chi.Router) {
r.With(auth.AdminsOnly).Post("/", h.dropFiles)
})
}