Implement device ID

This commit is contained in:
Magnus Åhall 2026-02-27 11:31:19 +01:00
parent 7213ee7a28
commit e0e2d9b164
4 changed files with 83 additions and 79 deletions

View file

@ -100,8 +100,7 @@ func actionDevices(w http.ResponseWriter, r *http.Request) { // {{{
} // }}}
func actionDeviceUpdate(w http.ResponseWriter, r *http.Request) { // {{{
var req struct {
CurrentName string
Device Device
Device Device
}
body, _ := io.ReadAll(r.Body)
@ -111,7 +110,7 @@ func actionDeviceUpdate(w http.ResponseWriter, r *http.Request) { // {{{
return
}
device, err := config.UpdateDevice(req.CurrentName, req.Device)
device, err := config.UpdateDevice(req.Device)
if err != nil {
httpError(w, err)
return
@ -128,9 +127,9 @@ func actionDeviceUpdate(w http.ResponseWriter, r *http.Request) { // {{{
w.Write(j)
} // }}}
func actionDeviceDelete(w http.ResponseWriter, r *http.Request) { // {{{
devname := r.PathValue("dev")
devID := r.PathValue("dev")
err := config.DeleteDevice(devname)
err := config.DeleteDevice(devID)
if err != nil {
httpError(w, err)
return
@ -141,9 +140,9 @@ func actionDeviceDelete(w http.ResponseWriter, r *http.Request) { // {{{
} // }}}
func actionDNSRecords(w http.ResponseWriter, r *http.Request) { // {{{
devname := r.PathValue("dev")
devID := r.PathValue("dev")
device, err := routerosDevice(devname)
device, err := routerosDevice(devID)
if err != nil {
httpError(w, err)
return