You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
759 B

3 days ago
#include "TestController.h"
#include "Core/LogManager.h"
#include <QMap>
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<std::string, std::string> 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;
}