http_website.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "http_define.h"
  3. #if USE_NET_HTTP_UTIL
  4. #include <functional>
  5. #include <map>
  6. #include <regex>
  7. #include "http_interface.h"
  8. #include "util/array.hpp"
  9. namespace ylib
  10. {
  11. namespace network
  12. {
  13. namespace http
  14. {
  15. class server;
  16. class router;
  17. class host;
  18. class agent;
  19. class website :public ylib::error_base, public network::http::interface_
  20. {
  21. public:
  22. public:
  23. website();
  24. ~website();
  25. /******************************************************************
  26. * function:启动
  27. * param
  28. * config : 配置项
  29. * return:
  30. * 失败可通过 last_error() 返回错误信息。
  31. ******************************************************************/
  32. bool start(const website_config& config);
  33. /******************************************************************
  34. * function:关闭
  35. ******************************************************************/
  36. void close();
  37. network::http::router* router();
  38. const website_config& config() { return m_config; }
  39. bool host(const std::string& host);
  40. bool is_catchall() const;
  41. ylib::nolock_array<network::http::proxy*>* proxy();
  42. private:
  43. // router路由 服务
  44. network::http::router* m_router = nullptr;
  45. // HOST
  46. std::vector<network::http::host*> m_hosts;
  47. // HTTPS
  48. bool m_https = false;
  49. // 反向代理
  50. ylib::nolock_array<network::http::proxy*> m_proxy;
  51. // 配置
  52. website_config m_config;
  53. };
  54. }
  55. }
  56. }
  57. #endif