62 static constexpr bool isAutoCreation = AutoCreation;
65 template <
typename FUNCTION>
66 static void registerMethod(
68 const std::string &pattern,
69 const std::vector<internal::HttpConstraint> &constraints = {},
70 bool classNameInPath =
true,
71 const std::string &handlerName =
"")
75 std::string path =
"/";
76 path.append(HttpController<T, AutoCreation>::classTypeName());
77 LOG_TRACE <<
"classname:"
78 << HttpController<T, AutoCreation>::classTypeName();
82 std::string::size_type pos;
83 while ((pos = path.find(
"::")) != std::string::npos)
85 path.replace(pos, 2,
"/");
87 if (pattern.empty() || pattern[0] ==
'/')
89 std::forward<FUNCTION>(function),
94 std::forward<FUNCTION>(function),
100 std::string path = pattern;
101 if (path.empty() || path[0] !=
'/')
106 std::forward<FUNCTION>(function),
112 template <
typename FUNCTION>
113 static void registerMethodViaRegex(
115 const std::string ®Exp,
116 const std::vector<internal::HttpConstraint> &constraints =
117 std::vector<internal::HttpConstraint>{},
118 const std::string &handlerName =
"")
121 std::forward<FUNCTION>(function),
127 class methodRegistrator
133 T::initPathRouting();
139 static methodRegistrator registrator_;
141 virtual void *touch()
143 return ®istrator_;
HttpAppFramework & registerHandlerViaRegex(const std::string ®Exp, FUNCTION &&function, const std::vector< internal::HttpConstraint > &constraints={}, const std::string &handlerName="")
Register a handler into the framework via a regular expression.
Definition HttpAppFramework.h:586
HttpAppFramework & registerHandler(const std::string &pathPattern, FUNCTION &&function, const std::vector< internal::HttpConstraint > &constraints={}, const std::string &handlerName="")
Register a handler into the framework.
Definition HttpAppFramework.h:535