::arg().set("retrieval-threads", "Number of AXFR-retrieval threads for slave operation")="2";
::arg().setSwitch("experimental-json-interface", "If the webserver should serve JSON data")="no";
+ ::arg().setSwitch("experimental-api-readonly", "If the JSON API should disallow data modification")="no";
::arg().setCmd("help","Provide a helpful message");
::arg().setCmd("version","Output version and compilation date");
#
# entropy-source=/dev/urandom
+#################################
+# experimental-api-readonly If the JSON API should disallow data modification
+#
+# experimental-api-readonly=no
+
#################################
# experimental-json-interface If the webserver should serve JSON data
#
static void apiServerZones(HttpRequest* req, HttpResponse* resp) {
UeberBackend B;
- if (req->method == "POST") {
+ if (req->method == "POST" && !::arg().mustDo("experimental-api-readonly")) {
DomainInfo di;
Document document;
req->json(document);
static void apiServerZoneDetail(HttpRequest* req, HttpResponse* resp) {
string zonename = apiZoneIdToName(req->path_parameters["id"]);
- if(req->method == "PUT") {
+ if(req->method == "PUT" && !::arg().mustDo("experimental-api-readonly")) {
// update domain settings
UeberBackend B;
DomainInfo di;
fillZone(zonename, resp);
return;
}
- else if(req->method == "DELETE") {
+ else if(req->method == "DELETE" && !::arg().mustDo("experimental-api-readonly")) {
// delete domain
UeberBackend B;
DomainInfo di;
// empty body on success
resp->body = "";
return;
- } else if (req->method == "PATCH") {
+ } else if (req->method == "PATCH" && !::arg().mustDo("experimental-api-readonly")) {
apiServerZoneRRset(req, resp);
return;
} else if (req->method == "GET") {
}
static void apiServerZoneRRset(HttpRequest* req, HttpResponse* resp) {
- if(req->method != "PATCH")
+ if(req->method != "PATCH" || ::arg().mustDo("experimental-api-readonly"))
throw HttpMethodNotAllowedException();
UeberBackend B;