2020-10-31 06:16:21 +13:00
|
|
|
package room
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-chi/chi"
|
|
|
|
|
2020-11-01 00:27:55 +13:00
|
|
|
"demodesk/neko/internal/api/utils"
|
2020-10-31 06:16:21 +13:00
|
|
|
"demodesk/neko/internal/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RoomHandler struct {
|
2020-11-02 04:54:06 +13:00
|
|
|
sessions types.SessionManager
|
|
|
|
desktop types.DesktopManager
|
|
|
|
capture types.CaptureManager
|
2020-10-31 06:16:21 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
func New(
|
|
|
|
sessions types.SessionManager,
|
2020-11-02 04:54:06 +13:00
|
|
|
desktop types.DesktopManager,
|
|
|
|
capture types.CaptureManager,
|
2020-10-31 06:16:21 +13:00
|
|
|
) *RoomHandler {
|
|
|
|
// Init
|
|
|
|
|
|
|
|
return &RoomHandler{
|
2020-11-02 04:54:06 +13:00
|
|
|
sessions: sessions,
|
|
|
|
desktop: desktop,
|
|
|
|
capture: capture,
|
2020-10-31 06:16:21 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-31 22:48:24 +13:00
|
|
|
func (h *RoomHandler) Router(
|
2020-11-01 00:27:55 +13:00
|
|
|
usersOnly utils.HttpMiddleware,
|
|
|
|
adminsOnly utils.HttpMiddleware,
|
2020-10-31 22:48:24 +13:00
|
|
|
) *chi.Mux {
|
2020-10-31 06:16:21 +13:00
|
|
|
r := chi.NewRouter()
|
|
|
|
|
2020-11-01 00:27:55 +13:00
|
|
|
r.Route("/screen", func(r chi.Router) {
|
|
|
|
r.With(usersOnly).Get("/", h.ScreenConfiguration)
|
|
|
|
r.With(adminsOnly).Post("/", h.ScreenConfigurationChange)
|
|
|
|
|
|
|
|
r.With(adminsOnly).Get("/configurations", h.ScreenConfigurationsList)
|
2020-10-31 22:48:24 +13:00
|
|
|
})
|
2020-10-31 06:16:21 +13:00
|
|
|
|
2020-11-01 00:35:02 +13:00
|
|
|
r.With(adminsOnly).Route("/clipboard", func(r chi.Router) {
|
|
|
|
r.Get("/", h.ClipboardRead)
|
|
|
|
r.Post("/", h.ClipboardWrite)
|
|
|
|
})
|
|
|
|
|
2020-10-31 06:16:21 +13:00
|
|
|
return r
|
|
|
|
}
|