exist sensor check in update sensor
This commit is contained in:
parent
f3ec170102
commit
2611b8c579
1 changed files with 6 additions and 0 deletions
|
@ -257,6 +257,12 @@ func (api *weatherRestApi) updateWeatherSensorHandler(w http.ResponseWriter, r *
|
||||||
}
|
}
|
||||||
sensor.Id = sensorId
|
sensor.Id = sensorId
|
||||||
|
|
||||||
|
exist, err := api.sensorRegistry.ExistSensor(sensorId)
|
||||||
|
if !exist || err != nil {
|
||||||
|
http.Error(w, "", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = api.sensorRegistry.UpdateSensor(&sensor)
|
err = api.sensorRegistry.UpdateSensor(&sensor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "", http.StatusBadRequest)
|
http.Error(w, "", http.StatusBadRequest)
|
||||||
|
|
Loading…
Add table
Reference in a new issue