drogon/examples/static_link_example/JsonTestController.cc

19 lines
548 B
C++
Executable File

#include "JsonTestController.h"
#include <json/json.h>
void JsonTestController::asyncHandleHttpRequest(const HttpRequest& req,std::function<void (HttpResponse &)>callback)
{
Json::Value json;
json["path"]="json";
json["name"]="json test";
Json::Value array;
for(int i=0;i<5;i++)
{
Json::Value user;
user["id"]=i;
user["name"]="none";
array.append(user);
}
json["rows"]=array;
auto resp=std::unique_ptr<HttpResponse>(HttpResponse::newHttpJsonResponse(json));
callback(*resp);
}