2019-03-30 15:09:22 +00:00
|
|
|
#pragma once
|
|
|
|
#include <drogon/HttpController.h>
|
|
|
|
using namespace drogon;
|
|
|
|
class CustomCtrl : public drogon::HttpController<CustomCtrl, false>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
METHOD_LIST_BEGIN
|
2019-05-18 12:39:57 +00:00
|
|
|
// use METHOD_ADD to add your custom processing function here;
|
|
|
|
METHOD_ADD(CustomCtrl::hello,
|
|
|
|
"/{1}",
|
|
|
|
Get,
|
|
|
|
"CustomHeaderFilter"); // path is /customctrl/{arg1}
|
2019-03-30 15:09:22 +00:00
|
|
|
METHOD_LIST_END
|
|
|
|
|
2019-05-18 12:39:57 +00:00
|
|
|
explicit CustomCtrl(const std::string &greetings) : _greetings(greetings)
|
|
|
|
{
|
|
|
|
}
|
2019-03-30 15:09:22 +00:00
|
|
|
|
2019-05-18 12:39:57 +00:00
|
|
|
void hello(const HttpRequestPtr &req,
|
|
|
|
std::function<void(const HttpResponsePtr &)> &&callback,
|
|
|
|
const std::string &userName) const;
|
2019-03-30 15:09:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _greetings;
|
|
|
|
};
|