httpHelper.hpp 964 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. *
  3. * httpHelper.h
  4. *
  5. */
  6. #pragma once
  7. #include <drogon/plugins/Plugin.h>
  8. #include <drogon/drogon.h>
  9. using namespace drogon;
  10. class httpHelper : public drogon::Plugin<httpHelper>
  11. {
  12. public:
  13. httpHelper() {}
  14. /// This method must be called by drogon to initialize and start the plugin.
  15. /// It must be implemented by the user.
  16. virtual void initAndStart(const Json::Value &config) override;
  17. /// This method must be called by drogon to shutdown the plugin.
  18. /// It must be implemented by the user.
  19. virtual void shutdown() override;
  20. /**
  21. * @description: 构建错误回复
  22. * @param {string} data
  23. * @return {*}
  24. */
  25. HttpResponsePtr makeWrongReply(std::string data);
  26. /**
  27. * @description: 应答回复
  28. * @param {pair<ReqResult, HttpResponsePtr>} result
  29. * @return {*}
  30. */
  31. HttpResponsePtr replyRequest(std::pair<ReqResult, HttpResponsePtr> result, const HttpMethod method);
  32. };