forked from the-benchmarker/web-frameworks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSyncPlugin.cc
More file actions
36 lines (32 loc) · 856 Bytes
/
SyncPlugin.cc
File metadata and controls
36 lines (32 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
*
* SyncPlugin.cc
*
*/
#include "SyncPlugin.h"
#include <drogon/drogon.h>
using namespace drogon;
void SyncPlugin::initAndStart(const Json::Value &config)
{
/// Initialize and start the plugin
drogon::app().registerSyncAdvice(
[](const HttpRequestPtr &req) -> HttpResponsePtr {
if (req->method() != Get || req->path().length() != 1)
{
return HttpResponsePtr{};
}
if (req->path() == "/")
{
auto resp = HttpResponse::newHttpResponse();
resp->setContentTypeCodeAndCustomString(
CT_TEXT_PLAIN, "Content-Type: text/plain\r\n");
return resp;
}
else
return HttpResponsePtr{};
});
}
void SyncPlugin::shutdown()
{
/// Shutdown the plugin
}