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 {
r := chi.NewRouter()
r.Route("/resolution", func(r chi.Router) {
r.Get("/", h.ResolutionGet)
r.Post("/", h.ResolutionChange)
r.Route("/screen", func(r chi.Router) {
r.Get("/", h.ScreenConfiguration)
r.Post("/", h.ScreenConfigurationChange)
r.Get("/list", h.ResolutionList)
r.Get("/configurations", h.ScreenConfigurationsList)
})
// TODO

View File

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