From: Aki Tuomi Date: Thu, 7 Dec 2023 15:22:31 +0000 (+0200) Subject: ws-auth: Add apiServerAutoprimaryDetailDELETE X-Git-Tag: auth-4.9.0-alpha1~42^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61fb497ad98d77dad8ded9e65892f2a4b73c1571;p=thirdparty%2Fpdns.git ws-auth: Add apiServerAutoprimaryDetailDELETE --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 2e2e370470..4ee6ac6e3b 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -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(); }