From 6745d703db0d07195a3ac040e051ed28e0d8595d Mon Sep 17 00:00:00 2001 From: antao Date: Sat, 20 Oct 2018 11:50:56 +0800 Subject: [PATCH] Modify HttpSimpleController.h --- lib/inc/drogon/HttpSimpleController.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/inc/drogon/HttpSimpleController.h b/lib/inc/drogon/HttpSimpleController.h index a166f0a0..8db0a84b 100755 --- a/lib/inc/drogon/HttpSimpleController.h +++ b/lib/inc/drogon/HttpSimpleController.h @@ -20,16 +20,17 @@ #include #include #include -#define PATH_LIST_BEGIN \ - static std::vector>> paths() \ - { \ - std::vector>> vet; +#define PATH_LIST_BEGIN \ + static void ___paths___() \ + { -#define PATH_ADD(path, filters...) \ - vet.push_back({path, {filters}}) +#define PATH_ADD(path, filters...) \ + { \ + LOG_TRACE << "register simple controller(" << classTypeName() << ") on path:" << path; \ + HttpAppFramework::instance().registerHttpSimpleController(path, classTypeName(), {filters}); \ + } #define PATH_LIST_END \ - return vet; \ } namespace drogon { @@ -55,13 +56,7 @@ class HttpSimpleController : public DrObject, public HttpSimpleControllerBase public: pathRegister() { - auto vPaths = T::paths(); - - for (auto path : vPaths) - { - LOG_TRACE << "register simple controller(" << HttpSimpleController::classTypeName() << ") on path:" << path.first; - HttpAppFramework::instance().registerHttpSimpleController(path.first, HttpSimpleController::classTypeName(), path.second); - } + T::___paths___(); } protected: