lib/api: Missing error handling in config handler (#8463)

This commit is contained in:
Jakob Borg 2022-07-28 17:35:43 +02:00 committed by GitHub
parent 755d21953f
commit 8b4bd43306
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -63,6 +63,10 @@ func (c *configMuxBuilder) registerFolders(path string) {
c.HandlerFunc(http.MethodPut, path, func(w http.ResponseWriter, r *http.Request) {
data, err := unmarshalToRawMessages(r.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
folders := make([]config.FolderConfiguration, len(data))
defaultFolder := c.cfg.DefaultFolder()
for i, bs := range data {
@ -94,6 +98,10 @@ func (c *configMuxBuilder) registerDevices(path string) {
c.HandlerFunc(http.MethodPut, path, func(w http.ResponseWriter, r *http.Request) {
data, err := unmarshalToRawMessages(r.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
devices := make([]config.DeviceConfiguration, len(data))
defaultDevice := c.cfg.DefaultDevice()
for i, bs := range data {