drogon/examples/simple_example/TestController.cc

18 lines
656 B
C++
Raw Normal View History

2018-05-14 08:57:40 +00:00
#include "TestController.h"
using namespace example;
2019-05-18 12:39:57 +00:00
void TestController::asyncHandleHttpRequest(
const HttpRequestPtr &req,
std::function<void(const HttpResponsePtr &)> &&callback)
2018-05-14 08:57:40 +00:00
{
2019-05-18 12:39:57 +00:00
// write your application logic here
LOG_WARN << req->matchedPathPatternData();
2019-11-21 03:27:47 +00:00
LOG_DEBUG << "index=" << threadIndex_.getThreadData();
++(threadIndex_.getThreadData());
2018-10-14 07:56:54 +00:00
auto resp = HttpResponse::newHttpResponse();
resp->setContentTypeCodeAndCustomString(CT_TEXT_PLAIN,
"Content-Type: plaintext\r\n");
2018-09-11 10:40:00 +00:00
resp->setBody("<p>Hello, world!</p>");
resp->setExpiredTime(20);
2018-08-26 08:25:35 +00:00
callback(resp);
2018-11-16 05:26:14 +00:00
}