exist sensor check in update sensor

This commit is contained in:
Joel Schmid 2021-08-22 13:42:48 +02:00
parent f3ec170102
commit 2611b8c579

View file

@ -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)