Format some files
This commit is contained in:
parent
159b5cebdd
commit
f35ff6347a
|
@ -5,15 +5,15 @@ namespace example
|
|||
{
|
||||
class TestController : public drogon::HttpSimpleController<TestController>
|
||||
{
|
||||
public:
|
||||
virtual void asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback) override;
|
||||
PATH_LIST_BEGIN
|
||||
//list path definations here;
|
||||
//PATH_ADD("/path","filter1","filter2",...);
|
||||
PATH_ADD("/");
|
||||
PATH_ADD("/Test", "nonFilter");
|
||||
PATH_ADD("/tpost", "drogon::PostFilter");
|
||||
PATH_ADD("/slow", "TimeFilter", Get);
|
||||
PATH_LIST_END
|
||||
public:
|
||||
virtual void asyncHandleHttpRequest(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback) override;
|
||||
PATH_LIST_BEGIN
|
||||
//list path definations here;
|
||||
//PATH_ADD("/path","filter1","filter2",...);
|
||||
PATH_ADD("/");
|
||||
PATH_ADD("/Test", "nonFilter");
|
||||
PATH_ADD("/tpost", "drogon::PostFilter");
|
||||
PATH_ADD("/slow", "TimeFilter", Get);
|
||||
PATH_LIST_END
|
||||
};
|
||||
} // namespace example
|
||||
|
|
|
@ -5,16 +5,16 @@ namespace api
|
|||
{
|
||||
class Attachment : public drogon::HttpController<Attachment>
|
||||
{
|
||||
public:
|
||||
METHOD_LIST_BEGIN
|
||||
//use METHOD_ADD to add your custom processing function here;
|
||||
METHOD_ADD(Attachment::get, "", Get); //Path will be '/api/attachment'
|
||||
METHOD_ADD(Attachment::upload,"/upload",Post);
|
||||
METHOD_LIST_END
|
||||
//your declaration of processing function maybe like this:
|
||||
void get(const HttpRequestPtr &req,
|
||||
const std::function<void(const HttpResponsePtr &)> &callback);
|
||||
void upload(const HttpRequestPtr &req,
|
||||
const std::function<void(const HttpResponsePtr &)> &callback);
|
||||
public:
|
||||
METHOD_LIST_BEGIN
|
||||
//use METHOD_ADD to add your custom processing function here;
|
||||
METHOD_ADD(Attachment::get, "", Get); //Path will be '/api/attachment'
|
||||
METHOD_ADD(Attachment::upload, "/upload", Post);
|
||||
METHOD_LIST_END
|
||||
//your declaration of processing function maybe like this:
|
||||
void get(const HttpRequestPtr &req,
|
||||
const std::function<void(const HttpResponsePtr &)> &callback);
|
||||
void upload(const HttpRequestPtr &req,
|
||||
const std::function<void(const HttpResponsePtr &)> &callback);
|
||||
};
|
||||
} // namespace api
|
||||
|
|
|
@ -7,19 +7,19 @@ namespace v1
|
|||
{
|
||||
class ApiTest : public drogon::HttpController<ApiTest>
|
||||
{
|
||||
public:
|
||||
METHOD_LIST_BEGIN
|
||||
//use METHOD_ADD to add your custom processing function here;
|
||||
METHOD_ADD(ApiTest::get, "/get/{2}/{1}", "drogon::GetFilter"); //path will be /api/v1/apitest/get/{arg2}/{arg1}
|
||||
METHOD_ADD(ApiTest::your_method_name, "/{1}/List?P2={2}", Get); //path will be /api/v1/apitest/{arg1}/list
|
||||
METHOD_ADD(ApiTest::staticApi, "/static", Get, Post);
|
||||
METHOD_ADD(ApiTest::get2, "/get/{1}", "drogon::GetFilter");
|
||||
METHOD_LIST_END
|
||||
//your declaration of processing function maybe like this:
|
||||
void get(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback, int p1, std::string &&p2);
|
||||
void your_method_name(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback, double p1, int p2) const;
|
||||
void staticApi(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback);
|
||||
void get2(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback, std::string &&p1);
|
||||
public:
|
||||
METHOD_LIST_BEGIN
|
||||
//use METHOD_ADD to add your custom processing function here;
|
||||
METHOD_ADD(ApiTest::get, "/get/{2}/{1}", "drogon::GetFilter"); //path will be /api/v1/apitest/get/{arg2}/{arg1}
|
||||
METHOD_ADD(ApiTest::your_method_name, "/{1}/List?P2={2}", Get); //path will be /api/v1/apitest/{arg1}/list
|
||||
METHOD_ADD(ApiTest::staticApi, "/static", Get, Post);
|
||||
METHOD_ADD(ApiTest::get2, "/get/{1}", "drogon::GetFilter");
|
||||
METHOD_LIST_END
|
||||
//your declaration of processing function maybe like this:
|
||||
void get(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback, int p1, std::string &&p2);
|
||||
void your_method_name(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback, double p1, int p2) const;
|
||||
void staticApi(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback);
|
||||
void get2(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback, std::string &&p1);
|
||||
};
|
||||
} // namespace v1
|
||||
} // namespace api
|
||||
|
|
|
@ -37,11 +37,11 @@ template <typename Function>
|
|||
struct FunctionTraits : public FunctionTraits<
|
||||
decltype(&std::remove_reference<Function>::type::operator())>
|
||||
{
|
||||
static const bool isClassFunction = false;
|
||||
static const std::string name()
|
||||
{
|
||||
return std::string("Functor");
|
||||
}
|
||||
static const bool isClassFunction = false;
|
||||
static const std::string name()
|
||||
{
|
||||
return std::string("Functor");
|
||||
}
|
||||
};
|
||||
|
||||
//class instance method of const object
|
||||
|
@ -52,9 +52,9 @@ template <
|
|||
struct FunctionTraits<
|
||||
ReturnType (ClassType::*)(Arguments...) const> : FunctionTraits<ReturnType (*)(Arguments...)>
|
||||
{
|
||||
static const bool isClassFunction = true;
|
||||
typedef ClassType class_type;
|
||||
static const std::string name() { return std::string("Class Function"); }
|
||||
static const bool isClassFunction = true;
|
||||
typedef ClassType class_type;
|
||||
static const std::string name() { return std::string("Class Function"); }
|
||||
};
|
||||
|
||||
//class instance method of non-const object
|
||||
|
@ -65,9 +65,9 @@ template <
|
|||
struct FunctionTraits<
|
||||
ReturnType (ClassType::*)(Arguments...)> : FunctionTraits<ReturnType (*)(Arguments...)>
|
||||
{
|
||||
static const bool isClassFunction = true;
|
||||
typedef ClassType class_type;
|
||||
static const std::string name() { return std::string("Class Function"); }
|
||||
static const bool isClassFunction = true;
|
||||
typedef ClassType class_type;
|
||||
static const std::string name() { return std::string("Class Function"); }
|
||||
};
|
||||
|
||||
//normal function for HTTP handling
|
||||
|
@ -77,7 +77,7 @@ template <
|
|||
struct FunctionTraits<
|
||||
ReturnType (*)(const HttpRequestPtr &req, const std::function<void(const HttpResponsePtr &)> &callback, Arguments...)> : FunctionTraits<ReturnType (*)(Arguments...)>
|
||||
{
|
||||
static const bool isHTTPFunction = true;
|
||||
static const bool isHTTPFunction = true;
|
||||
};
|
||||
|
||||
//normal function
|
||||
|
@ -87,18 +87,18 @@ template <
|
|||
struct FunctionTraits<
|
||||
ReturnType (*)(Arguments...)>
|
||||
{
|
||||
typedef ReturnType result_type;
|
||||
typedef ReturnType result_type;
|
||||
|
||||
template <std::size_t Index>
|
||||
using argument = typename std::tuple_element<
|
||||
Index,
|
||||
std::tuple<Arguments...>>::type;
|
||||
template <std::size_t Index>
|
||||
using argument = typename std::tuple_element<
|
||||
Index,
|
||||
std::tuple<Arguments...>>::type;
|
||||
|
||||
static const std::size_t arity = sizeof...(Arguments);
|
||||
static const std::size_t arity = sizeof...(Arguments);
|
||||
|
||||
static const bool isHTTPFunction = false;
|
||||
static const bool isClassFunction = false;
|
||||
static const std::string name() { return std::string("Normal or Static Function"); }
|
||||
static const bool isHTTPFunction = false;
|
||||
static const bool isClassFunction = false;
|
||||
static const std::string name() { return std::string("Normal or Static Function"); }
|
||||
};
|
||||
|
||||
} // namespace utility
|
||||
|
|
Loading…
Reference in New Issue