From: Peter van Dijk Date: Tue, 3 Jun 2025 12:50:21 +0000 (+0200) Subject: auth views REST: don't wrap list around single network X-Git-Tag: dnsdist-2.1.0-alpha0~7^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec702c191e257ebaed5a4b4ab588df6c9d0745a8;p=thirdparty%2Fpdns.git auth views REST: don't wrap list around single network --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 0463cb8a96..6dd7536ed8 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -2778,13 +2778,18 @@ static void apiServerNetworksGET(HttpRequest* req, HttpResponse* resp) item.clear(); } - if (!network.empty() && jsonarray.empty()) { - throw HttpNotFoundException(); // no views configured for that network + if (network.empty()) { + Json::object jsonresult{ + {"networks", std::move(jsonarray)}}; + resp->setJsonBody(jsonresult); } + else { + if (jsonarray.empty()) { + throw HttpNotFoundException(); // no view configured for that network + } - Json::object jsonresult{ - {"networks", std::move(jsonarray)}}; - resp->setJsonBody(jsonresult); + resp->setJsonBody(jsonarray[0]); + } } // PUT /networks// sets the name of the view for the given network