From: Christian Hofstaedtler Date: Mon, 28 Dec 2015 00:54:32 +0000 (+0100) Subject: API: port /server/:server/statistics to json11 X-Git-Tag: dnsdist-1.0.0-alpha2~123^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9aeac747dbe8b4b947b5269dd4c4226917f55de0;p=thirdparty%2Fpdns.git API: port /server/:server/statistics to json11 --- diff --git a/pdns/ws-api.cc b/pdns/ws-api.cc index a2e1695863..a816b86256 100644 --- a/pdns/ws-api.cc +++ b/pdns/ws-api.cc @@ -79,8 +79,6 @@ strcasestr(const char *s1, const char *s2) #endif // HAVE_STRCASESTR -using namespace rapidjson; - static Json getServerDetail() { return Json::object { { "type", "Server" }, @@ -184,21 +182,14 @@ void apiServerStatistics(HttpRequest* req, HttpResponse* resp) { map items; productServerStatisticsFetch(items); - Document doc; - doc.SetArray(); + Json::array doc; typedef map items_t; - for(const items_t::value_type& item : items) { - Value jitem; - jitem.SetObject(); - jitem.AddMember("type", "StatisticItem", doc.GetAllocator()); - - Value jname(item.first.c_str(), doc.GetAllocator()); - jitem.AddMember("name", jname, doc.GetAllocator()); - - Value jvalue(item.second.c_str(), doc.GetAllocator()); - jitem.AddMember("value", jvalue, doc.GetAllocator()); - - doc.PushBack(jitem, doc.GetAllocator()); + for(const items_t::value_type& item : items) { + doc.push_back(Json::object { + { "type", "StatisticItem" }, + { "name", item.first }, + { "value", item.second }, + }); } resp->setBody(doc); diff --git a/pdns/ws-api.hh b/pdns/ws-api.hh index fd0071976c..201cf07a8d 100644 --- a/pdns/ws-api.hh +++ b/pdns/ws-api.hh @@ -23,9 +23,6 @@ #define PDNS_WSAPI_HH #include -#include "rapidjson/document.h" -#include "rapidjson/stringbuffer.h" -#include "rapidjson/writer.h" #include "webserver.hh" void apiServer(HttpRequest* req, HttpResponse* resp);