2018-05-21 10:54:00 +00:00
|
|
|
#include "JsonTestController.h"
|
|
|
|
#include <json/json.h>
|
2018-10-14 07:56:54 +00:00
|
|
|
void JsonTestController::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback)
|
2018-05-21 10:54:00 +00:00
|
|
|
{
|
|
|
|
Json::Value json;
|
2018-10-14 07:56:54 +00:00
|
|
|
json["path"] = "json";
|
|
|
|
json["name"] = "json test";
|
2018-05-21 10:54:00 +00:00
|
|
|
Json::Value array;
|
2018-10-14 07:56:54 +00:00
|
|
|
for (int i = 0; i < 5; i++)
|
2018-05-21 10:54:00 +00:00
|
|
|
{
|
|
|
|
Json::Value user;
|
2018-10-14 07:56:54 +00:00
|
|
|
user["id"] = i;
|
|
|
|
user["name"] = "none";
|
2018-05-21 10:54:00 +00:00
|
|
|
array.append(user);
|
|
|
|
}
|
2018-10-14 07:56:54 +00:00
|
|
|
json["rows"] = array;
|
|
|
|
auto resp = HttpResponse::newHttpJsonResponse(json);
|
2018-08-26 08:25:35 +00:00
|
|
|
callback(resp);
|
2018-05-21 10:54:00 +00:00
|
|
|
}
|