resolution -> screen configuration.

This commit is contained in:
Miroslav Šedivý 2020-10-30 21:28:07 +01:00
parent d48b857dfe
commit 9343e85b8f
2 changed files with 11 additions and 11 deletions

View File

@ -32,11 +32,11 @@ func New(
func (h *RoomHandler) Router() *chi.Mux { func (h *RoomHandler) Router() *chi.Mux {
r := chi.NewRouter() r := chi.NewRouter()
r.Route("/resolution", func(r chi.Router) { r.Route("/screen", func(r chi.Router) {
r.Get("/", h.ResolutionGet) r.Get("/", h.ScreenConfiguration)
r.Post("/", h.ResolutionChange) r.Post("/", h.ScreenConfigurationChange)
r.Get("/list", h.ResolutionList) r.Get("/configurations", h.ScreenConfigurationsList)
}) })
// TODO // TODO

View File

@ -8,17 +8,17 @@ import (
"demodesk/neko/internal/api/utils" "demodesk/neko/internal/api/utils"
) )
type ResolutionStruct struct { type ScreenConfiguration struct {
Width int `json:"width"` Width int `json:"width"`
Height int `json:"height"` Height int `json:"height"`
Rate int `json:"rate"` Rate int `json:"rate"`
} }
func (a *ResolutionStruct) Bind(r *http.Request) error { func (a *ScreenConfiguration) Bind(r *http.Request) error {
return nil return nil
} }
func (h *RoomHandler) ResolutionGet(w http.ResponseWriter, r *http.Request) { func (h *RoomHandler) ScreenConfiguration(w http.ResponseWriter, r *http.Request) {
size := h.remote.GetScreenSize() size := h.remote.GetScreenSize()
if size == nil { if size == nil {
@ -26,15 +26,15 @@ func (h *RoomHandler) ResolutionGet(w http.ResponseWriter, r *http.Request) {
return return
} }
render.JSON(w, r, ResolutionStruct{ render.JSON(w, r, ScreenConfiguration{
Width: size.Width, Width: size.Width,
Height: size.Height, Height: size.Height,
Rate: int(size.Rate), Rate: int(size.Rate),
}) })
} }
func (h *RoomHandler) ResolutionChange(w http.ResponseWriter, r *http.Request) { func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.Request) {
data := &ResolutionStruct{} data := &ScreenConfiguration{}
if err := render.Bind(r, data); err != nil { if err := render.Bind(r, data); err != nil {
render.Render(w, r, utils.ErrInvalidRequest(err)) render.Render(w, r, utils.ErrInvalidRequest(err))
return return
@ -50,6 +50,6 @@ func (h *RoomHandler) ResolutionChange(w http.ResponseWriter, r *http.Request) {
render.JSON(w, r, data) render.JSON(w, r, data)
} }
func (h *RoomHandler) ResolutionList(w http.ResponseWriter, r *http.Request) { func (h *RoomHandler) ScreenConfigurationsList(w http.ResponseWriter, r *http.Request) {
render.Render(w, r, utils.ErrMessage(500, "Not implmented.")) render.Render(w, r, utils.ErrMessage(500, "Not implmented."))
} }