return string(output.GetString(), output.Size());
}
-string returnJsonObject(const map<string, string>& items)
-{
- Document doc;
- doc.SetObject();
- typedef map<string, string> items_t;
- for(const items_t::value_type& val : items) {
- doc.AddMember(val.first.c_str(), val.second.c_str(), doc.GetAllocator());
- }
- return makeStringFromDocument(doc);
-}
-
string returnJsonError(const string& error)
{
Document doc;
#include "rapidjson/document.h"
#include "json11.hpp"
-std::string returnJsonObject(const std::map<std::string, std::string>& items);
std::string returnJsonError(const std::string& error);
std::string returnJsonMessage(const std::string& message);
std::string makeStringFromDocument(const rapidjson::Document& doc);
extern PacketCache PC;
int count = PC.purgeExact(canon);
-
- map<string, string> object;
- object["count"] = std::to_string(count);
- object["result"] = "Flushed cache.";
- resp->body = returnJsonObject(object);
+ resp->setBody(Json::object {
+ { "count", count },
+ { "result", "Flushed cache." }
+ });
}
void AuthWebServer::cssfunction(HttpRequest* req, HttpResponse* resp)
int count = broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, canon, false));
count += broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, canon, false));
count += broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, canon, false));
- map<string, string> object;
- object["count"] = std::to_string(count);
- object["result"] = "Flushed cache.";
- resp->body = returnJsonObject(object);
+ resp->setBody(Json::object {
+ { "count", count },
+ { "result", "Flushed cache." }
+ });
}
RecursorWebServer::RecursorWebServer(FDMultiplexer* fdm)