From ec702c191e257ebaed5a4b4ab588df6c9d0745a8 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Tue, 3 Jun 2025 14:50:21 +0200 Subject: [PATCH] auth views REST: don't wrap list around single network --- pdns/ws-auth.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 -- 2.47.2