Comment

Comment by an-tao

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.

parent an-tao 7 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton