From 2611b8c579704f82763d501ef50c13cafd05abde Mon Sep 17 00:00:00 2001 From: Joel Schmid Date: Sun, 22 Aug 2021 13:42:48 +0200 Subject: [PATCH] exist sensor check in update sensor --- api/rest-api.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/rest-api.go b/api/rest-api.go index 874696e..d09759d 100644 --- a/api/rest-api.go +++ b/api/rest-api.go @@ -257,6 +257,12 @@ func (api *weatherRestApi) updateWeatherSensorHandler(w http.ResponseWriter, r * } sensor.Id = sensorId + exist, err := api.sensorRegistry.ExistSensor(sensorId) + if !exist || err != nil { + http.Error(w, "", http.StatusNotFound) + return + } + err = api.sensorRegistry.UpdateSensor(&sensor) if err != nil { http.Error(w, "", http.StatusBadRequest)