/dhcp/find_active_dhcp API — Don't return 'found' key when there's an error. And return error string.

This commit is contained in:
Eugene Bujak 2018-12-28 20:50:00 +03:00
parent 6fd9af3c60
commit f5e7eed447
1 changed files with 4 additions and 5 deletions

View File

@ -110,12 +110,11 @@ func handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) {
// implement
func handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) {
found, err := dhcpd.CheckIfOtherDHCPServersPresent(config.DHCP.InterfaceName)
result := map[string]interface{}{
"found": found,
}
result := map[string]interface{}{}
if err != nil {
result["found"] = false
result["error"] = err
result["error"] = err.Error()
} else {
result["found"] = found
}
w.Header().Set("Content-Type", "application/json")
err = json.NewEncoder(w).Encode(result)