Delete device, better device edit dialog
This commit is contained in:
parent
e92022f1f1
commit
06054c8d39
4 changed files with 155 additions and 30 deletions
13
webserver.go
13
webserver.go
|
|
@ -35,6 +35,7 @@ func registerWebserverHandlers() { // {{{
|
|||
http.HandleFunc("/", rootHandler)
|
||||
http.HandleFunc("GET /devices", actionDevices)
|
||||
http.HandleFunc("POST /device", actionDeviceUpdate)
|
||||
http.HandleFunc("DELETE /device/{dev}", actionDeviceDelete)
|
||||
http.HandleFunc("GET /device/{dev}/dns_records", actionDNSRecords)
|
||||
http.HandleFunc("POST /device/{dev}/record", actionRecordSave)
|
||||
http.HandleFunc("DELETE /device/{dev}/record/{id}", actionRecordDelete)
|
||||
|
|
@ -126,6 +127,18 @@ func actionDeviceUpdate(w http.ResponseWriter, r *http.Request) { // {{{
|
|||
})
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
func actionDeviceDelete(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
devname := r.PathValue("dev")
|
||||
|
||||
err := config.DeleteDevice(devname)
|
||||
if err != nil {
|
||||
httpError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
j, _ := json.Marshal(struct{ OK bool }{true})
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
|
||||
func actionDNSRecords(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
devname := r.PathValue("dev")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue