diff --git a/drogon_ctl/create_controller.cc b/drogon_ctl/create_controller.cc index 14dda28c..24169cd4 100755 --- a/drogon_ctl/create_controller.cc +++ b/drogon_ctl/create_controller.cc @@ -150,7 +150,45 @@ void create_controller::newSimpleControllerSourceFile(std::ofstream &file,const file<<" //write your application logic here\n"; file<<"}"; } -void create_controller::createApiController(std::vector &apiPaths) +void create_controller::createApiController(std::vector &apiClasses) +{ + for(auto iter=apiClasses.begin();iter!=apiClasses.end();iter++) + { + if ((*iter)[0] == '-') + { + std::cout< &ctlNames,const std::string &namespaceName=""); void createSimpleController(const std::string &ctlName,const std::string &namespaceName=""); - void createApiController(std::vector &apiPaths); + void createApiController(std::vector &apiClasses); + void createApiController(const std::string &className); void newSimpleControllerHeaderFile(std::ofstream &file,const std::string &ctlName,const std::string &namespaceName=""); void newSimpleControllerSourceFile(std::ofstream &file,const std::string &ctlName,const std::string &namespaceName=""); + void newApiControllerHeaderFile(std::ofstream &file,const std::string &className); + void newApiControllerSourceFile(std::ofstream &file,const std::string &className); + }; } diff --git a/examples/static_link_example/main.cc b/examples/static_link_example/main.cc index 1cb919a9..fa280ee6 100755 --- a/examples/static_link_example/main.cc +++ b/examples/static_link_example/main.cc @@ -70,12 +70,12 @@ int main() B b; //functor - drogon::HttpAppFramework::registerHttpApiMethod("/api/v1/handle3","",b); + drogon::HttpAppFramework::registerHttpApiMethod("/api/v1/handle3","/{1}/{2}",b); A tmp; std::function&,int,const std::string &,const std::string &,int)> func=std::bind(&A::handle,&tmp,_1,_2,_3,_4,_5,_6); - //std::function + //api example for std::function drogon::HttpAppFramework::registerHttpApiMethod("/api/v1/handle4","",func); LOG_DEBUG<::value) - { - //out of std::bind -// typedef decltype(&std::remove_reference::type::operator ()) OperType; -// binder=std::make_shared< -// HttpApiBinder -// >(std::forward(function)); - } - else - { - binder=std::make_shared< - HttpApiBinder - >(std::forward(function)); - } + binder=std::make_shared< + HttpApiBinder + >(std::forward(function)); instance().registerHttpApiController(pathName,parameterPattern,binder,filters); } -// template -// static void registerHttpApiBind(const std::string &pathName, -// const std::string ¶meterPattern, -// const std::function & function, -// const std::vector &filters=std::vector()) -// { -// HttpApiBinderBasePtr binder=std::make_shared< -// HttpApiBinder -// >(std::forward(function)); -// instance().registerHttpApiController(pathName,parameterPattern,binder,filters); -// } virtual void enableSession(const size_t timeout=0)=0; virtual void disableSession()=0; };