|
|
|
|
|
by an-tao
2653 days ago
|
|
You can register handler like this in Drogon: drogon::app.registerHttpMethod("/test",
[=](const HttpRequestPtr& req,
const std::function<void (const HttpResponsePtr &)> & callback)
{
Json::Value json;
json["result"]="ok";
auto resp=HttpResponse::newHttpJsonResponse(json);
callback(resp);
},
{Get,"LoginFilter"});
The method in the readme file is for decoupling. Imagine a scene with dozens of path handlers. Isn't it better to disperse them in their respective classes?Of course, for very simple logic, the interface you are talking about is really more intuitive, I will consider adding such an interface. Thank you for your comment. |
|