http_server.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Copyright (c) 2023 Sogou, Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #ifndef __RPC_HTTP_SERVER_H__
  14. #define __RPC_HTTP_SERVER_H__
  15. #include "workflow/WFHttpServer.h"
  16. #include "rpc_basic.h"
  17. #include "rpc_filter.h"
  18. #include "rpc_module.h"
  19. namespace srpc
  20. {
  21. class HttpServer : public WFHttpServer
  22. {
  23. public:
  24. HttpServer(http_process_t proc) :
  25. WFHttpServer(std::move(proc)),
  26. listen_port(0)
  27. {
  28. }
  29. void add_filter(RPCFilter *filter);
  30. protected:
  31. CommSession *new_session(long long seq, CommConnection *conn) override;
  32. private:
  33. unsigned short get_listen_port();
  34. private:
  35. std::mutex mutex;
  36. RPCModule *modules[SRPC_MODULE_MAX] = { NULL };
  37. unsigned short listen_port;
  38. };
  39. } // namespace srpc
  40. #endif