]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth views REST: don't wrap list around single network
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 3 Jun 2025 12:50:21 +0000 (14:50 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 3 Jun 2025 12:50:21 +0000 (14:50 +0200)
pdns/ws-auth.cc

index 0463cb8a9662bc21e7ae0d2cf73a992b6784d2e7..6dd7536ed85234723bf50ca9ab6bf00bed5dfc74 100644 (file)
@@ -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/<ip>/<prefixlen> sets the name of the view for the given network