mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-11-30 10:47:40 +08:00
Fix framework bugs
This commit is contained in:
parent
1c47395bb8
commit
a6fe81a003
@ -7,15 +7,16 @@ namespace api
|
||||
{
|
||||
class ApiTest:public drogon::HttpApiController<ApiTest>
|
||||
{
|
||||
METHOD_LIST_BEGIN
|
||||
//use METHOD_ADD to add your custom processing function here;
|
||||
METHOD_ADD(ApiTest::get,"/{2}/{1}",1,"drogon::GetFilter");//path will be /api/v1/ApiTest/get/{arg2}/{arg1}
|
||||
METHOD_ADD(ApiTest::your_method_name,"/{1}/list?p2={2}",0,"drogon::GetFilter");//path will be /api/v1/ApiTest/{arg1}/list
|
||||
|
||||
METHOD_LIST_END
|
||||
//your declaration of processing function maybe like this:
|
||||
void get(const HttpRequestPtr& req,const std::function<void (HttpResponse &)>&callback,int p1,std::string p2);
|
||||
void your_method_name(const HttpRequestPtr& req,const std::function<void (HttpResponse &)>&callback,double p1,int p2) const;
|
||||
public:
|
||||
METHOD_LIST_BEGIN
|
||||
//use METHOD_ADD to add your custom processing function here;
|
||||
METHOD_ADD(ApiTest::get,"/{2}/{1}",1,"drogon::GetFilter");//path will be /api/v1/ApiTest/get/{arg2}/{arg1}
|
||||
METHOD_ADD(ApiTest::your_method_name,"/{1}/list?p2={2}",0,"drogon::GetFilter");//path will be /api/v1/ApiTest/{arg1}/list
|
||||
|
||||
METHOD_LIST_END
|
||||
//your declaration of processing function maybe like this:
|
||||
void get(const HttpRequestPtr& req,const std::function<void (HttpResponse &)>&callback,int p1,std::string p2);
|
||||
void your_method_name(const HttpRequestPtr& req,const std::function<void (HttpResponse &)>&callback,double p1,int p2) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ namespace api
|
||||
{
|
||||
class Test:public HttpApiController<Test>
|
||||
{
|
||||
public:
|
||||
METHOD_LIST_BEGIN
|
||||
METHOD_ADD(Test::get,"/{2}/{1}",1,"drogon::GetFilter");//path will be /api/v1/test/get/{arg2}/{arg1}
|
||||
METHOD_ADD(Test::list,"/{2}/info",0,"drogon::GetFilter");//path will be /api/v1/test/{arg2}/info
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#define METHOD_LIST_BEGIN public:\
|
||||
#define METHOD_LIST_BEGIN \
|
||||
static void initMethods() \
|
||||
{
|
||||
#define METHOD_ADD(method,pattern,isMethodNameInPath,filters...) \
|
||||
@ -41,7 +41,9 @@ static void initMethods() \
|
||||
|
||||
#define METHOD_LIST_END \
|
||||
return;\
|
||||
}
|
||||
}\
|
||||
protected:
|
||||
|
||||
namespace drogon
|
||||
{
|
||||
template <typename T>
|
||||
|
@ -579,6 +579,14 @@ void HttpAppFrameworkImpl::onAsyncRequest(const HttpRequestPtr& req,const std::f
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
//No controller found
|
||||
auto res=drogon::HttpResponse::notFoundResponse();
|
||||
if(needSetJsessionid)
|
||||
res->addCookie("JSESSIONID",session_id);
|
||||
|
||||
callback(*res);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//No controller found
|
||||
|
Loading…
Reference in New Issue
Block a user