#include "TestController.h" #include "Core/LogManager.h" #include TestController::TestController() {} int TestController::get(HttpRequest *req, HttpResponse *resp) { Q_UNUSED(req); return resp->String("Test"); } int TestController::post(HttpRequest *req, HttpResponse *resp) { nlohmann::json data = nlohmann::json::parse(req->body.c_str()); LOG_INFO << QString::fromStdString(data.dump()); QMap map; map.insert("code", "200"); map.insert("msg", "this is a json demo !"); return resp->Json(map.toStdMap()); } int TestController::put(HttpRequest *req, HttpResponse *resp) { resp->json["code"] = 200; resp->json["params1"] = req->query_params["params1"]; return HTTP_STATUS_OK; }