2018-05-14 08:57:40 +00:00
|
|
|
#include "TestController.h"
|
2018-05-29 05:49:26 +00:00
|
|
|
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
|
2019-07-26 14:22:12 +00:00
|
|
|
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();
|
2019-07-26 14:22:12 +00:00
|
|
|
resp->setContentTypeCodeAndCustomString(CT_TEXT_PLAIN,
|
|
|
|
"Content-Type: plaintext\r\n");
|
2018-09-11 10:40:00 +00:00
|
|
|
resp->setBody("<p>Hello, world!</p>");
|
2019-10-03 02:17:54 +00:00
|
|
|
resp->setExpiredTime(20);
|
2018-08-26 08:25:35 +00:00
|
|
|
callback(resp);
|
2018-11-16 05:26:14 +00:00
|
|
|
}
|