]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
ws-auth: Add apiServerAutoprimaryDetailDELETE
authorAki Tuomi <cmouse@cmouse.fi>
Thu, 7 Dec 2023 15:22:31 +0000 (17:22 +0200)
committerAki Tuomi <cmouse@cmouse.fi>
Fri, 15 Dec 2023 07:59:57 +0000 (09:59 +0200)
pdns/ws-auth.cc

index 2e2e370470aebe366549b71bf81818a93f159711..4ee6ac6e3b1cd232b867d8f49d124bb58d16c478 100644 (file)
@@ -1716,14 +1716,19 @@ static void apiServerTSIGKeyDetail(HttpRequest* req, HttpResponse* resp) {
     throw HttpMethodNotAllowedException();
 }
 
+static void apiServerAutoprimaryDetailDELETE(HttpRequest* req, HttpResponse* resp) {
+  UeberBackend B; // NOLINT(readability-identifier-length)
+  const AutoPrimary& primary{req->parameters["ip"], req->parameters["nameserver"], ""};
+  if (!B.autoPrimaryRemove(primary)) {
+     throw HttpInternalServerErrorException("Cannot find backend with autoprimary feature");
+  }
+  resp->body = "";
+  resp->status = 204;
+}
+
 static void apiServerAutoprimaryDetail(HttpRequest* req, HttpResponse* resp) {
-  UeberBackend B;
   if (req->method == "DELETE") {
-    const AutoPrimary primary(req->parameters["ip"], req->parameters["nameserver"], "");
-    if (!B.autoPrimaryRemove(primary))
-       throw HttpInternalServerErrorException("Cannot find backend with autoprimary feature");
-    resp->body = "";
-    resp->status = 204;
+    apiServerAutoprimaryDetailDELETE(req, resp);
   } else {
     throw HttpMethodNotAllowedException();
   }