* /control/dhcp/find_active_dhcp: new JSON response format
This commit is contained in:
parent
b453d9f41d
commit
8b6e9ef5f9
19
dhcp.go
19
dhcp.go
|
@ -147,13 +147,22 @@ func handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, errorText, http.StatusBadRequest)
|
http.Error(w, errorText, http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
found, err := dhcpd.CheckIfOtherDHCPServersPresent(interfaceName)
|
found, err := dhcpd.CheckIfOtherDHCPServersPresent(interfaceName)
|
||||||
result := map[string]interface{}{}
|
|
||||||
if err != nil {
|
othSrv := map[string]interface{}{}
|
||||||
result["error"] = err.Error()
|
foundVal := "no"
|
||||||
} else {
|
if found {
|
||||||
result["found"] = found
|
foundVal = "yes"
|
||||||
|
} else if err != nil {
|
||||||
|
foundVal = "error"
|
||||||
|
othSrv["error"] = err.Error()
|
||||||
}
|
}
|
||||||
|
othSrv["found"] = foundVal
|
||||||
|
|
||||||
|
result := map[string]interface{}{}
|
||||||
|
result["other-server"] = othSrv
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
err = json.NewEncoder(w).Encode(result)
|
err = json.NewEncoder(w).Encode(result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue