Modify HttpSimpleController.h

This commit is contained in:
antao 2018-10-20 11:50:56 +08:00
parent acc26c0776
commit 6745d703db

View File

@ -20,16 +20,17 @@
#include <string>
#include <vector>
#include <iostream>
#define PATH_LIST_BEGIN \
static std::vector<std::pair<std::string, std::vector<std::string>>> paths() \
{ \
std::vector<std::pair<std::string, std::vector<std::string>>> 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<T>, public HttpSimpleControllerBase
public:
pathRegister()
{
auto vPaths = T::paths();
for (auto path : vPaths)
{
LOG_TRACE << "register simple controller(" << HttpSimpleController<T>::classTypeName() << ") on path:" << path.first;
HttpAppFramework::instance().registerHttpSimpleController(path.first, HttpSimpleController<T>::classTypeName(), path.second);
}
T::___paths___();
}
protected: