lib/api: Missing error handling in config handler (#8463)
This commit is contained in:
@@ -63,6 +63,10 @@ func (c *configMuxBuilder) registerFolders(path string) {
|
|||||||
|
|
||||||
c.HandlerFunc(http.MethodPut, path, func(w http.ResponseWriter, r *http.Request) {
|
c.HandlerFunc(http.MethodPut, path, func(w http.ResponseWriter, r *http.Request) {
|
||||||
data, err := unmarshalToRawMessages(r.Body)
|
data, err := unmarshalToRawMessages(r.Body)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
folders := make([]config.FolderConfiguration, len(data))
|
folders := make([]config.FolderConfiguration, len(data))
|
||||||
defaultFolder := c.cfg.DefaultFolder()
|
defaultFolder := c.cfg.DefaultFolder()
|
||||||
for i, bs := range data {
|
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) {
|
c.HandlerFunc(http.MethodPut, path, func(w http.ResponseWriter, r *http.Request) {
|
||||||
data, err := unmarshalToRawMessages(r.Body)
|
data, err := unmarshalToRawMessages(r.Body)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
devices := make([]config.DeviceConfiguration, len(data))
|
devices := make([]config.DeviceConfiguration, len(data))
|
||||||
defaultDevice := c.cfg.DefaultDevice()
|
defaultDevice := c.cfg.DefaultDevice()
|
||||||
for i, bs := range data {
|
for i, bs := range data {
|
||||||
|
|||||||
Reference in New Issue
Block a user