mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add settings update to API.
This commit is contained in:
parent
7d53e59945
commit
58fca708a7
@ -55,6 +55,11 @@ func New(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) Route(r types.Router) {
|
func (h *RoomHandler) Route(r types.Router) {
|
||||||
|
r.With(auth.AdminsOnly).Route("/settings", func(r types.Router) {
|
||||||
|
r.Post("/", h.settingsSet)
|
||||||
|
r.Get("/", h.settingsGet)
|
||||||
|
})
|
||||||
|
|
||||||
r.With(auth.AdminsOnly).Route("/broadcast", func(r types.Router) {
|
r.With(auth.AdminsOnly).Route("/broadcast", func(r types.Router) {
|
||||||
r.Get("/", h.broadcastStatus)
|
r.Get("/", h.broadcastStatus)
|
||||||
r.Post("/start", h.boradcastStart)
|
r.Post("/start", h.boradcastStart)
|
||||||
@ -108,6 +113,7 @@ func (h *RoomHandler) Route(r types.Router) {
|
|||||||
r.Post("/dialog", h.uploadDialogPost)
|
r.Post("/dialog", h.uploadDialogPost)
|
||||||
r.Delete("/dialog", h.uploadDialogClose)
|
r.Delete("/dialog", h.uploadDialogClose)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RoomHandler) uploadMiddleware(w http.ResponseWriter, r *http.Request) (context.Context, error) {
|
func (h *RoomHandler) uploadMiddleware(w http.ResponseWriter, r *http.Request) (context.Context, error) {
|
||||||
|
24
internal/api/room/settings.go
Normal file
24
internal/api/room/settings.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package room
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"gitlab.com/demodesk/neko/server/pkg/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (h *RoomHandler) settingsGet(w http.ResponseWriter, r *http.Request) error {
|
||||||
|
settings := h.sessions.Settings()
|
||||||
|
return utils.HttpSuccess(w, settings)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *RoomHandler) settingsSet(w http.ResponseWriter, r *http.Request) error {
|
||||||
|
settings := h.sessions.Settings()
|
||||||
|
|
||||||
|
if err := utils.HttpJsonRequest(w, r, &settings); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
h.sessions.UpdateSettings(settings)
|
||||||
|
|
||||||
|
return utils.HttpSuccess(w)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user