api_v1_apps.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <drogon/HttpController.h>
  3. #include <drogon/drogon.h>
  4. using namespace drogon;
  5. namespace api
  6. {
  7. namespace v1
  8. {
  9. class apps : public drogon::HttpController<apps>
  10. {
  11. public:
  12. METHOD_LIST_BEGIN
  13. // use METHOD_ADD to add your custom processing function here;
  14. METHOD_ADD(apps::getTemplate, "/template?token={1}&name={2}", Get, "LoginFilter"); // path is /api/v1/apps/template?token={1}
  15. METHOD_ADD(apps::getAIList, "AIList?token={1}", Get, "LoginFilter");
  16. METHOD_ADD(apps::getAI, "AI?token={1}&name={2}", Get, "LoginFilter");
  17. METHOD_ADD(apps::postAI, "AI?token={1}&name={2}&uri={3}", Post, "LoginFilter");
  18. METHOD_ADD(apps::deleteAI, "AI?token={1}&name={2}", Delete, "LoginFilter");
  19. METHOD_LIST_END
  20. // your declaration of processing function maybe like this:
  21. void getTemplate(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
  22. void getAIList(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token);
  23. // AI
  24. void getAI(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
  25. void postAI(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name, std::string uri);
  26. void deleteAI(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback, std::string token, std::string name);
  27. };
  28. }
  29. }