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