Sfoglia il codice sorgente

Update Drogon to the latest version (#4811)

An Tao 6 anni fa
parent
commit
fdc0b06a91
24 ha cambiato i file con 116 aggiunte e 42 eliminazioni
  1. 1 1
      frameworks/C++/drogon/drogon-raw.dockerfile
  2. 1 1
      frameworks/C++/drogon/drogon.dockerfile
  3. 38 3
      frameworks/C++/drogon/drogon_benchmark/config-raw.json
  4. 38 3
      frameworks/C++/drogon/drogon_benchmark/config.json
  5. 2 2
      frameworks/C++/drogon/drogon_benchmark/controllers/DbCtrl.cc
  6. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/DbCtrl.h
  7. 2 2
      frameworks/C++/drogon/drogon_benchmark/controllers/DbCtrlRaw.cc
  8. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/DbCtrlRaw.h
  9. 7 5
      frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrl.cc
  10. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrl.h
  11. 7 5
      frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrlRaw.cc
  12. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrlRaw.h
  13. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/JsonCtrl.cc
  14. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/JsonCtrl.h
  15. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/PlaintextCtrl.cc
  16. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/PlaintextCtrl.h
  17. 2 2
      frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrl.cc
  18. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrl.h
  19. 2 2
      frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrlRaw.cc
  20. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrlRaw.h
  21. 2 2
      frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrl.cc
  22. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrl.h
  23. 2 2
      frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrlRaw.cc
  24. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrlRaw.h

+ 1 - 1
frameworks/C++/drogon/drogon-raw.dockerfile

@@ -34,7 +34,7 @@ RUN git clone https://github.com/an-tao/drogon
 
 WORKDIR $DROGON_ROOT
 
-RUN git checkout 92d7867ee4eeaf072cf7112f7773661a26d3c185
+RUN git checkout 32836a0fef0a9a1061ac92ef87bd269edb2e1734
 
 RUN ./build.sh
 

+ 1 - 1
frameworks/C++/drogon/drogon.dockerfile

@@ -34,7 +34,7 @@ RUN git clone https://github.com/an-tao/drogon
 
 WORKDIR $DROGON_ROOT
 
-RUN git checkout 92d7867ee4eeaf072cf7112f7773661a26d3c185
+RUN git checkout 32836a0fef0a9a1061ac92ef87bd269edb2e1734
 
 RUN ./build.sh
 

+ 38 - 3
frameworks/C++/drogon/drogon_benchmark/config-raw.json

@@ -134,6 +134,41 @@
         ],
         //idle_connection_timeout: defaults to 60 seconds, the lifetime 
         //of the connection without read or write
-        "idle_connection_timeout": 60
-    }
-}
+        "idle_connection_timeout": 60,
+        //server_header_field: Set the 'server' header field in each response sent by drogon,
+        //empty string by default with which the 'server' header field is set to "Server: drogon/version string\r\n"
+        "server_header_field": "",
+        //keepalive_requests: Set the maximum number of requests that can be served through one keep-alive connection. 
+        //After the maximum number of requests are made, the connection is closed.
+        //The default value of 0 means no limit.
+        "keepalive_requests": 0,
+        //pipelining_requests: Set the maximum number of unhandled requests that can be cached in pipelining buffer. 
+        //After the maximum number of requests are made, the connection is closed.
+        //The default value of 0 means no limit.
+        "pipelining_requests": 0,
+        //gzip_static: If it is set to true, when the client requests a static file, drogon first finds the compressed 
+        //file with the extension ".gz" in the same path and send the compressed file to the client.
+        //The default value of gzip_static is true.
+        "gzip_static": true,
+        //client_max_body_size: Set the max body size of HTTP requests received by drogon. The default value is "1M".
+        //One can set it to "1024", "1k", "10M", "1G", etc. Setting it to "" means no limit.
+        "client_max_body_size": "1M",
+        //client_max_websocket_message_size: Set the max size of messages sent by WebSocket client. The default value is "128K".
+        //One can set it to "1024", "1k", "10M", "1G", etc. Setting it to "" means no limit.
+        "client_max_websocket_message_size": "128K"
+    },
+    //plugins: Define all plugins running in the application
+    "plugins": [{
+        //name: The class name of the plugin
+        //"name": "TestPlugin",
+        //dependencies: Plugins that the plugin depends on. It can be commented out
+        "dependencies": [],
+        //config: The configuration of the plugin. This json object is the parameter to initialize the plugin.
+        //It can be commented out
+        "config": {
+            "heartbeat_interval": 2
+        }
+    }],
+    //custom_config: custom configuration for users. This object can be get by the app().getCustomConfig() method. 
+    "custom_config": {}
+}

+ 38 - 3
frameworks/C++/drogon/drogon_benchmark/config.json

@@ -150,6 +150,41 @@
         ],
         //idle_connection_timeout: defaults to 60 seconds, the lifetime 
         //of the connection without read or write
-        "idle_connection_timeout": 60
-    }
-}
+        "idle_connection_timeout": 60,
+        //server_header_field: Set the 'server' header field in each response sent by drogon,
+        //empty string by default with which the 'server' header field is set to "Server: drogon/version string\r\n"
+        "server_header_field": "",
+        //keepalive_requests: Set the maximum number of requests that can be served through one keep-alive connection. 
+        //After the maximum number of requests are made, the connection is closed.
+        //The default value of 0 means no limit.
+        "keepalive_requests": 0,
+        //pipelining_requests: Set the maximum number of unhandled requests that can be cached in pipelining buffer. 
+        //After the maximum number of requests are made, the connection is closed.
+        //The default value of 0 means no limit.
+        "pipelining_requests": 0,
+        //gzip_static: If it is set to true, when the client requests a static file, drogon first finds the compressed 
+        //file with the extension ".gz" in the same path and send the compressed file to the client.
+        //The default value of gzip_static is true.
+        "gzip_static": true,
+        //client_max_body_size: Set the max body size of HTTP requests received by drogon. The default value is "1M".
+        //One can set it to "1024", "1k", "10M", "1G", etc. Setting it to "" means no limit.
+        "client_max_body_size": "1M",
+        //client_max_websocket_message_size: Set the max size of messages sent by WebSocket client. The default value is "128K".
+        //One can set it to "1024", "1k", "10M", "1G", etc. Setting it to "" means no limit.
+        "client_max_websocket_message_size": "128K"
+    },
+    //plugins: Define all plugins running in the application
+    "plugins": [{
+        //name: The class name of the plugin
+        //"name": "TestPlugin",
+        //dependencies: Plugins that the plugin depends on. It can be commented out
+        "dependencies": [],
+        //config: The configuration of the plugin. This json object is the parameter to initialize the plugin.
+        //It can be commented out
+        "config": {
+            "heartbeat_interval": 2
+        }
+    }],
+    //custom_config: custom configuration for users. This object can be get by the app().getCustomConfig() method. 
+    "custom_config": {}
+}

+ 2 - 2
frameworks/C++/drogon/drogon_benchmark/controllers/DbCtrl.cc

@@ -6,7 +6,7 @@
 #include <time.h>
 using namespace drogon_model::hello_world;
 
-void DbCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback)
+void DbCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
 {
     //write your application logic here
     static std::once_flag once;
@@ -15,7 +15,7 @@ void DbCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::functi
     });
     auto client = drogon::app().getFastDbClient();
 
-    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(callback));
+    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(std::move(callback)));
     drogon::orm::Mapper<World> mapper(client);
     World::PrimaryKeyType id = rand() % 10000 + 1;
     mapper.findByPrimaryKey(id,

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/DbCtrl.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class DbCtrl:public drogon::HttpSimpleController<DbCtrl>
 {
 public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback) override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;
     PATH_LIST_BEGIN
     //list path definitions here;
     //PATH_ADD("/db", Get);

+ 2 - 2
frameworks/C++/drogon/drogon_benchmark/controllers/DbCtrlRaw.cc

@@ -8,14 +8,14 @@ using namespace drogon_model::hello_world;
 
 void DbCtrlRaw::asyncHandleHttpRequest(
     const HttpRequestPtr &req,
-    const std::function<void(const HttpResponsePtr &)> &callback)
+    std::function<void(const HttpResponsePtr &)> &&callback)
 {
     // write your application logic here
     static std::once_flag once;
     std::call_once(once, []() { srand(time(NULL)); });
     auto client = drogon::app().getFastDbClient();
     int id = rand() % 10000 + 1;
-    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(callback));
+    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(std::move(callback)));
 
     *client << "select randomnumber from world where id=$1" << id >>
         [callbackPtr, id](const Result &rows) {

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/DbCtrlRaw.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class DbCtrlRaw:public drogon::HttpSimpleController<DbCtrlRaw>
 {
 public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback) override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;
     PATH_LIST_BEGIN
     //list path definitions here;
     //PATH_ADD("/db", Get);

+ 7 - 5
frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrl.cc

@@ -3,11 +3,13 @@
 #include <algorithm>
 
 using namespace drogon_model::hello_world;
-void FortuneCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback)
+void FortuneCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
 {
     auto client = drogon::app().getFastDbClient();
     drogon::orm::Mapper<Fortune> mapper(client);
-    mapper.findAll([callback](std::vector<Fortune> rows) {
+    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(std::move(callback)));
+
+    mapper.findAll([callbackPtr](std::vector<Fortune> rows) {
                         Fortune newRow;
                         newRow.setId(0);
                         newRow.setMessage("Additional fortune added at request time.");
@@ -25,10 +27,10 @@ void FortuneCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::f
                         HttpViewData data;
                         data.insert("rows",std::move(rows));
                         auto resp=HttpResponse::newHttpViewResponse("fortune.csp",data);
-                        callback(resp); },
-                   [callback](const DrogonDbException &err) {
+                        (*callbackPtr)(resp); },
+                   [callbackPtr](const DrogonDbException &err) {
                        auto resp = HttpResponse::newHttpResponse();
                        resp->setBody(std::string("error:") + err.base().what());
-                       callback(resp);
+                       (*callbackPtr)(resp);
                    });
 }

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrl.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class FortuneCtrl:public drogon::HttpSimpleController<FortuneCtrl>
 {
 public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback) override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;
     PATH_LIST_BEGIN
     //list path definitions here;
     PATH_LIST_END

+ 7 - 5
frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrlRaw.cc

@@ -3,12 +3,14 @@
 #include <algorithm>
 
 using namespace drogon_model::hello_world;
-void FortuneCtrlRaw::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback)
+void FortuneCtrlRaw::asyncHandleHttpRequest(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
 {
     auto client = drogon::app().getFastDbClient();
+    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(std::move(callback)));
+
     *client << "select * from fortune where 1=$1"
             << 1 >>
-        [callback](const Result &r) {
+        [callbackPtr](const Result &r) {
             std::vector<std::pair<int, std::string>> rows;
             for (auto row : r)
             {
@@ -23,11 +25,11 @@ void FortuneCtrlRaw::asyncHandleHttpRequest(const HttpRequestPtr &req, const std
             HttpViewData data;
             data.insert("rows", std::move(rows));
             auto resp = HttpResponse::newHttpViewResponse("fortune_raw.csp", data);
-            callback(resp);
+            (*callbackPtr)(resp);
         } >>
-        [callback](const DrogonDbException &err) {
+        [callbackPtr](const DrogonDbException &err) {
             auto resp = HttpResponse::newHttpResponse();
             resp->setBody(std::string("error:") + err.base().what());
-            callback(resp);
+            (*callbackPtr)(resp);
         };
 }

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrlRaw.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class FortuneCtrlRaw:public drogon::HttpSimpleController<FortuneCtrlRaw>
 {
 public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback) override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;
     PATH_LIST_BEGIN
     //list path definitions here;
     PATH_LIST_END

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/JsonCtrl.cc

@@ -1,5 +1,5 @@
 #include "JsonCtrl.h"
-void JsonCtrl::asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback)
+void JsonCtrl::asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback)
 {
     Json::Value ret;
     ret["message"]="Hello, World!";

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/JsonCtrl.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class JsonCtrl:public drogon::HttpSimpleController<JsonCtrl>
 {
 public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback)override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback)override;
     PATH_LIST_BEGIN
     //list path definitions here;
     //PATH_ADD("/json",Get);

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/PlaintextCtrl.cc

@@ -1,5 +1,5 @@
 #include "PlaintextCtrl.h"
-void PlaintextCtrl::asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback)
+void PlaintextCtrl::asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback)
 {
     auto resp = HttpResponse::newHttpResponse();
     resp->setBody("Hello, World!");

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/PlaintextCtrl.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class PlaintextCtrl:public drogon::HttpSimpleController<PlaintextCtrl>
 {
 public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback)override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback)override;
     PATH_LIST_BEGIN
     //list path definitions here;
     //PATH_ADD("/plaintext",Get);

+ 2 - 2
frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrl.cc

@@ -4,7 +4,7 @@
 
 using namespace drogon_model::hello_world;
 
-void QueriesCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback)
+void QueriesCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
 {
     //write your application logic here
     static std::once_flag once;
@@ -23,7 +23,7 @@ void QueriesCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::f
     }
     auto json = std::make_shared<Json::Value>();
     json->resize(0);
-    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(callback));
+    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(std::move(callback)));
     auto counter = std::make_shared<int>(queries);
     auto client = app().getFastDbClient();
     drogon::orm::Mapper<World> mapper(client);

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrl.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class QueriesCtrl : public drogon::HttpSimpleController<QueriesCtrl>
 {
   public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback) override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback) override;
     PATH_LIST_BEGIN
     //list path definitions here;
     //PATH_ADD("/path","filter1","filter2",HttpMethod1,HttpMethod2...);

+ 2 - 2
frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrlRaw.cc

@@ -1,6 +1,6 @@
 #include "QueriesCtrlRaw.h"
 using namespace drogon::orm;
-void QueriesCtrlRaw::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback)
+void QueriesCtrlRaw::asyncHandleHttpRequest(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
 {
     //write your application logic here
     static std::once_flag once;
@@ -19,7 +19,7 @@ void QueriesCtrlRaw::asyncHandleHttpRequest(const HttpRequestPtr &req, const std
     }
     auto json = std::make_shared<Json::Value>();
     json->resize(0);
-    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(callback));
+    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(std::move(callback)));
     auto counter = std::make_shared<int>(queries);
     auto client = app().getFastDbClient();
     for (int i = 0; i < queries; i++)

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrlRaw.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class QueriesCtrlRaw:public drogon::HttpSimpleController<QueriesCtrlRaw>
 {
 public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback) override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;
     PATH_LIST_BEGIN
     //list path definitions here;
     //PATH_ADD("/path","filter1","filter2",HttpMethod1,HttpMethod2...);

+ 2 - 2
frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrl.cc

@@ -4,7 +4,7 @@
 
 using namespace drogon_model::hello_world;
 
-void UpdatesCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback)
+void UpdatesCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
 {
     //write your application logic here
     static std::once_flag once;
@@ -23,7 +23,7 @@ void UpdatesCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::f
     }
     auto json = std::make_shared<Json::Value>();
     json->resize(0);
-    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(callback));
+    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(std::move(callback)));
     auto counter = std::make_shared<int>(queries);
     auto client = app().getFastDbClient();
     drogon::orm::Mapper<World> mapper(client);

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrl.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class UpdatesCtrl : public drogon::HttpSimpleController<UpdatesCtrl>
 {
   public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback) override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback) override;
     PATH_LIST_BEGIN
     //list path definitions here;
     //PATH_ADD("/path","filter1","filter2",HttpMethod1,HttpMethod2...);

+ 2 - 2
frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrlRaw.cc

@@ -56,7 +56,7 @@ const void update(const std::shared_ptr<std::vector<Result>> &results,
             (*callbackPtr)(resp);
         };
 }
-void UpdatesCtrlRaw::asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback)
+void UpdatesCtrlRaw::asyncHandleHttpRequest(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
 {
     //write your application logic here
     static std::once_flag once;
@@ -75,7 +75,7 @@ void UpdatesCtrlRaw::asyncHandleHttpRequest(const HttpRequestPtr &req, const std
     }
     auto json = std::make_shared<Json::Value>();
     json->resize(0);
-    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(callback));
+    auto callbackPtr = std::shared_ptr<std::function<void(const HttpResponsePtr &)>>(new std::function<void(const HttpResponsePtr &)>(std::move(callback)));
     auto resultSetPtr = std::make_shared<std::vector<Result>>();
     resultSetPtr->reserve(queries);
     auto client = app().getFastDbClient();

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrlRaw.h

@@ -4,7 +4,7 @@ using namespace drogon;
 class UpdatesCtrlRaw:public drogon::HttpSimpleController<UpdatesCtrlRaw>
 {
 public:
-    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)> & callback) override;
+    virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;
     PATH_LIST_BEGIN
     //list path definitions here;
     //PATH_ADD("/path","filter1","filter2",HttpMethod1,HttpMethod2...);