http_website.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #include "util/localstorage.h"
  10. namespace ylib
  11. {
  12. namespace network
  13. {
  14. namespace http
  15. {
  16. class server;
  17. class router;
  18. class host;
  19. class agent;
  20. class cache;
  21. class cdn;
  22. class website :public ylib::error_base, public network::http::interface_
  23. {
  24. public:
  25. public:
  26. website();
  27. ~website();
  28. /******************************************************************
  29. * function:启动
  30. * param
  31. * config : 配置项
  32. * return:
  33. * 失败可通过 last_error() 返回错误信息。
  34. ******************************************************************/
  35. bool start(const website_config& config);
  36. /******************************************************************
  37. * function:关闭
  38. ******************************************************************/
  39. void close();
  40. network::http::router* router();
  41. inline network::http::cache* cache() { return m_cache; }
  42. inline network::http::cdn* cdn() { return m_cdn; }
  43. ylib::local_storage* session() { return m_session_local_storage; }
  44. const website_config& config() { return m_config; }
  45. bool host(const std::string& host);
  46. ylib::nolock_array<network::http::proxy*>* proxy();
  47. private:
  48. // 文件缓存
  49. network::http::cache* m_cache = nullptr;
  50. // SESSION缓存
  51. ylib::local_storage* m_session_local_storage = nullptr;
  52. // router路由 服务
  53. network::http::router* m_router = nullptr;
  54. // CDN服务
  55. network::http::cdn* m_cdn = nullptr;
  56. // HOST
  57. std::vector<network::http::host*> m_hosts;
  58. // HTTPS
  59. bool m_https = false;
  60. // 反向代理
  61. ylib::nolock_array<network::http::proxy*> m_proxy;
  62. // 配置
  63. website_config m_config;
  64. };
  65. }
  66. }
  67. }
  68. #endif