From 9eb7025d74385d12f1fa653259f7571a00d40f0c Mon Sep 17 00:00:00 2001 From: An Tao Date: Tue, 19 Mar 2019 23:21:14 +0800 Subject: [PATCH] Update README.md --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 21936564..1dcc0726 100755 --- a/README.md +++ b/README.md @@ -64,7 +64,23 @@ int main() } ``` -Drogon provides some interfaces for adding controller logic directly in the main() function, but unless your logic is very simple, we don't recommend using them. Instead, we create an HttpSimpleController as follows: +Drogon provides some interfaces for adding controller logic directly in the main() function, for example, user can register a handler like this in Drogon: + +```c++ +app.registerHttpMethod("/test", + [=](const HttpRequestPtr& req, + const std::function & callback) + { + Json::Value json; + json["result"]="ok"; + auto resp=HttpResponse::newHttpJsonResponse(json); + callback(resp); + }, + {Get,"LoginFilter"}); +``` + + +In a scene with dozens of path handlers, isn't it better to disperse them in their respective classes? So unless your logic is very simple, we don't recommend using above interfaces. Instead, we create an HttpSimpleController as follows: ```c++ /// The TestCtrl.h file