From f5e7eed44762f1258f54b7c641b025087230b966 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Fri, 28 Dec 2018 20:50:00 +0300 Subject: [PATCH] =?UTF-8?q?/dhcp/find=5Factive=5Fdhcp=20API=20=E2=80=94=20?= =?UTF-8?q?Don't=20return=20'found'=20key=20when=20there's=20an=20error.?= =?UTF-8?q?=20And=20return=20error=20string.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dhcp.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dhcp.go b/dhcp.go index 738f8dad..d025b6b5 100644 --- a/dhcp.go +++ b/dhcp.go @@ -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)