/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 // implement
func handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) { func handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) {
found, err := dhcpd.CheckIfOtherDHCPServersPresent(config.DHCP.InterfaceName) found, err := dhcpd.CheckIfOtherDHCPServersPresent(config.DHCP.InterfaceName)
result := map[string]interface{}{ result := map[string]interface{}{}
"found": found,
}
if err != nil { if err != nil {
result["found"] = false result["error"] = err.Error()
result["error"] = err } else {
result["found"] = found
} }
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)